diff --git a/packages/nodes-base/.eslintrc.js b/packages/nodes-base/.eslintrc.js index 5bc2bdf8e8..da98b9a9b3 100644 --- a/packages/nodes-base/.eslintrc.js +++ b/packages/nodes-base/.eslintrc.js @@ -14,31 +14,14 @@ module.exports = { 'id-denylist': 'off', 'import/extensions': 'off', 'import/order': 'off', - 'prefer-const': 'off', 'prefer-spread': 'off', 'import/no-extraneous-dependencies': 'off', - '@typescript-eslint/array-type': 'off', - '@typescript-eslint/await-thenable': 'off', - '@typescript-eslint/ban-types': 'off', - '@typescript-eslint/default-param-last': 'off', - '@typescript-eslint/dot-notation': 'off', - '@typescript-eslint/lines-between-class-members': 'off', - '@typescript-eslint/member-delimiter-style': 'off', '@typescript-eslint/naming-convention': ['error', { selector: 'memberLike', format: null }], - '@typescript-eslint/no-duplicate-imports': 'off', - '@typescript-eslint/no-empty-interface': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-floating-promises': 'off', - '@typescript-eslint/no-for-in-array': 'off', - '@typescript-eslint/no-invalid-void-type': 'off', - '@typescript-eslint/no-loop-func': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-shadow': 'off', + '@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-this-alias': 'off', '@typescript-eslint/no-throw-literal': 'off', - '@typescript-eslint/no-unnecessary-type-assertion': 'off', - '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off', '@typescript-eslint/no-unnecessary-qualifier': 'off', '@typescript-eslint/no-unsafe-argument': 'off', '@typescript-eslint/no-unsafe-assignment': 'off', @@ -49,11 +32,8 @@ module.exports = { '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/prefer-nullish-coalescing': 'off', - '@typescript-eslint/prefer-optional-chain': 'off', - '@typescript-eslint/promise-function-async': 'off', '@typescript-eslint/restrict-plus-operands': 'off', '@typescript-eslint/restrict-template-expressions': 'off', - '@typescript-eslint/return-await': 'off', '@typescript-eslint/unbound-method': 'off', '@typescript-eslint/ban-ts-comment': ['warn', { 'ts-ignore': true }], }, diff --git a/packages/nodes-base/credentials/ActionNetworkApi.credentials.ts b/packages/nodes-base/credentials/ActionNetworkApi.credentials.ts index 273d938678..29344cd6ff 100644 --- a/packages/nodes-base/credentials/ActionNetworkApi.credentials.ts +++ b/packages/nodes-base/credentials/ActionNetworkApi.credentials.ts @@ -8,8 +8,11 @@ import { export class ActionNetworkApi implements ICredentialType { name = 'actionNetworkApi'; + displayName = 'Action Network API'; + documentationUrl = 'actionNetwork'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -19,12 +22,14 @@ export class ActionNetworkApi implements ICredentialType { default: '', }, ]; + test: ICredentialTestRequest = { request: { baseURL: 'https://actionnetwork.org/api/v2', url: '/events?per_page=1', }, }; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, diff --git a/packages/nodes-base/credentials/ActiveCampaignApi.credentials.ts b/packages/nodes-base/credentials/ActiveCampaignApi.credentials.ts index e68622d479..3d384a0974 100644 --- a/packages/nodes-base/credentials/ActiveCampaignApi.credentials.ts +++ b/packages/nodes-base/credentials/ActiveCampaignApi.credentials.ts @@ -7,8 +7,11 @@ import { export class ActiveCampaignApi implements ICredentialType { name = 'activeCampaignApi'; + displayName = 'ActiveCampaign API'; + documentationUrl = 'activeCampaign'; + properties: INodeProperties[] = [ { displayName: 'API URL', @@ -24,6 +27,7 @@ export class ActiveCampaignApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -32,6 +36,7 @@ export class ActiveCampaignApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials.apiUrl}}', diff --git a/packages/nodes-base/credentials/AcuitySchedulingApi.credentials.ts b/packages/nodes-base/credentials/AcuitySchedulingApi.credentials.ts index 477bc14051..71b2210abd 100644 --- a/packages/nodes-base/credentials/AcuitySchedulingApi.credentials.ts +++ b/packages/nodes-base/credentials/AcuitySchedulingApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class AcuitySchedulingApi implements ICredentialType { name = 'acuitySchedulingApi'; + displayName = 'Acuity Scheduling API'; + documentationUrl = 'acuityScheduling'; + properties: INodeProperties[] = [ { displayName: 'User ID', diff --git a/packages/nodes-base/credentials/AcuitySchedulingOAuth2Api.credentials.ts b/packages/nodes-base/credentials/AcuitySchedulingOAuth2Api.credentials.ts index a86aa39807..7bfd01500e 100644 --- a/packages/nodes-base/credentials/AcuitySchedulingOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/AcuitySchedulingOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class AcuitySchedulingOAuth2Api implements ICredentialType { name = 'acuitySchedulingOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'AcuityScheduling OAuth2 API'; + documentationUrl = 'acuityScheduling'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/AdaloApi.credentials.ts b/packages/nodes-base/credentials/AdaloApi.credentials.ts index 036198e7fd..fd09f22ab7 100644 --- a/packages/nodes-base/credentials/AdaloApi.credentials.ts +++ b/packages/nodes-base/credentials/AdaloApi.credentials.ts @@ -2,8 +2,11 @@ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-work export class AdaloApi implements ICredentialType { name = 'adaloApi'; + displayName = 'Adalo API'; + documentationUrl = 'adalo'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/AffinityApi.credentials.ts b/packages/nodes-base/credentials/AffinityApi.credentials.ts index 66e184449e..8771344974 100644 --- a/packages/nodes-base/credentials/AffinityApi.credentials.ts +++ b/packages/nodes-base/credentials/AffinityApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class AffinityApi implements ICredentialType { name = 'affinityApi'; + displayName = 'Affinity API'; + documentationUrl = 'affinity'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/AgileCrmApi.credentials.ts b/packages/nodes-base/credentials/AgileCrmApi.credentials.ts index 28f5c2af65..719cb1afa3 100644 --- a/packages/nodes-base/credentials/AgileCrmApi.credentials.ts +++ b/packages/nodes-base/credentials/AgileCrmApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class AgileCrmApi implements ICredentialType { name = 'agileCrmApi'; + displayName = 'AgileCRM API'; + documentationUrl = 'agileCrm'; + properties: INodeProperties[] = [ { displayName: 'Email', diff --git a/packages/nodes-base/credentials/AirtableApi.credentials.ts b/packages/nodes-base/credentials/AirtableApi.credentials.ts index f803e0b696..2e3db309a2 100644 --- a/packages/nodes-base/credentials/AirtableApi.credentials.ts +++ b/packages/nodes-base/credentials/AirtableApi.credentials.ts @@ -2,8 +2,11 @@ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-work export class AirtableApi implements ICredentialType { name = 'airtableApi'; + displayName = 'Airtable API'; + documentationUrl = 'airtable'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -13,6 +16,7 @@ export class AirtableApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/Amqp.credentials.ts b/packages/nodes-base/credentials/Amqp.credentials.ts index acc5836e84..3477cf3232 100644 --- a/packages/nodes-base/credentials/Amqp.credentials.ts +++ b/packages/nodes-base/credentials/Amqp.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Amqp implements ICredentialType { name = 'amqp'; + displayName = 'AMQP'; + documentationUrl = 'amqp'; + properties: INodeProperties[] = [ { displayName: 'Hostname', diff --git a/packages/nodes-base/credentials/ApiTemplateIoApi.credentials.ts b/packages/nodes-base/credentials/ApiTemplateIoApi.credentials.ts index 9eb4c350bc..44c8721562 100644 --- a/packages/nodes-base/credentials/ApiTemplateIoApi.credentials.ts +++ b/packages/nodes-base/credentials/ApiTemplateIoApi.credentials.ts @@ -7,8 +7,11 @@ import { export class ApiTemplateIoApi implements ICredentialType { name = 'apiTemplateIoApi'; + displayName = 'APITemplate.io API'; + documentationUrl = 'apiTemplateIo'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class ApiTemplateIoApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class ApiTemplateIoApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.apitemplate.io/v1', diff --git a/packages/nodes-base/credentials/AsanaApi.credentials.ts b/packages/nodes-base/credentials/AsanaApi.credentials.ts index 57dfe9aed1..c5be8c1add 100644 --- a/packages/nodes-base/credentials/AsanaApi.credentials.ts +++ b/packages/nodes-base/credentials/AsanaApi.credentials.ts @@ -2,8 +2,11 @@ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-work export class AsanaApi implements ICredentialType { name = 'asanaApi'; + displayName = 'Asana API'; + documentationUrl = 'asana'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/AsanaOAuth2Api.credentials.ts b/packages/nodes-base/credentials/AsanaOAuth2Api.credentials.ts index 8a0baf67f8..d15e7832c3 100644 --- a/packages/nodes-base/credentials/AsanaOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/AsanaOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class AsanaOAuth2Api implements ICredentialType { name = 'asanaOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Asana OAuth2 API'; + documentationUrl = 'asana'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/AutomizyApi.credentials.ts b/packages/nodes-base/credentials/AutomizyApi.credentials.ts index 259c1c01a4..c3ea0e47e3 100644 --- a/packages/nodes-base/credentials/AutomizyApi.credentials.ts +++ b/packages/nodes-base/credentials/AutomizyApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class AutomizyApi implements ICredentialType { name = 'automizyApi'; + displayName = 'Automizy API'; + documentationUrl = 'automizy'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/AutopilotApi.credentials.ts b/packages/nodes-base/credentials/AutopilotApi.credentials.ts index 420cc4eb5a..abc552ddcc 100644 --- a/packages/nodes-base/credentials/AutopilotApi.credentials.ts +++ b/packages/nodes-base/credentials/AutopilotApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class AutopilotApi implements ICredentialType { name = 'autopilotApi'; + displayName = 'Autopilot API'; + documentationUrl = 'autopilot'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/Aws.credentials.ts b/packages/nodes-base/credentials/Aws.credentials.ts index 8269b10268..db7ae9b505 100644 --- a/packages/nodes-base/credentials/Aws.credentials.ts +++ b/packages/nodes-base/credentials/Aws.credentials.ts @@ -1,7 +1,8 @@ import { Request, sign } from 'aws4'; -import { ICredentialTestRequest } from 'n8n-workflow'; + import { ICredentialDataDecryptedObject, + ICredentialTestRequest, ICredentialType, IDataObject, IHttpRequestOptions, @@ -125,9 +126,13 @@ export type AWSRegion = typeof regions[number]['name']; export class Aws implements ICredentialType { name = 'aws'; + displayName = 'AWS'; + documentationUrl = 'aws'; + icon = 'file:AWS.svg'; + properties: INodeProperties[] = [ { displayName: 'Region', @@ -302,8 +307,8 @@ export class Aws implements ICredentialType { } else { // If no endpoint is set, we try to decompose the path and use the default endpoint const customUrl = new URL(`${requestOptions.baseURL!}${requestOptions.url}${path ?? ''}`); - service = customUrl.hostname.split('.')[0] as string; - region = customUrl.hostname.split('.')[1] as string; + service = customUrl.hostname.split('.')[0]; + region = customUrl.hostname.split('.')[1]; if (service === 'sts') { try { customUrl.searchParams.set('Action', 'GetCallerIdentity'); diff --git a/packages/nodes-base/credentials/BambooHrApi.credentials.ts b/packages/nodes-base/credentials/BambooHrApi.credentials.ts index ae138e1015..590003f40e 100644 --- a/packages/nodes-base/credentials/BambooHrApi.credentials.ts +++ b/packages/nodes-base/credentials/BambooHrApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BambooHrApi implements ICredentialType { name = 'bambooHrApi'; + displayName = 'BambooHR API'; + documentationUrl = 'bambooHr'; + properties: INodeProperties[] = [ { displayName: 'Subdomain', diff --git a/packages/nodes-base/credentials/BannerbearApi.credentials.ts b/packages/nodes-base/credentials/BannerbearApi.credentials.ts index 28a67b8892..fccea60a47 100644 --- a/packages/nodes-base/credentials/BannerbearApi.credentials.ts +++ b/packages/nodes-base/credentials/BannerbearApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BannerbearApi implements ICredentialType { name = 'bannerbearApi'; + displayName = 'Bannerbear API'; + documentationUrl = 'bannerbear'; + properties: INodeProperties[] = [ { displayName: 'Project API Key', diff --git a/packages/nodes-base/credentials/BaserowApi.credentials.ts b/packages/nodes-base/credentials/BaserowApi.credentials.ts index 5be62849e5..3a944efb83 100644 --- a/packages/nodes-base/credentials/BaserowApi.credentials.ts +++ b/packages/nodes-base/credentials/BaserowApi.credentials.ts @@ -4,7 +4,9 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BaserowApi implements ICredentialType { name = 'baserowApi'; + displayName = 'Baserow API'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/BeeminderApi.credentials.ts b/packages/nodes-base/credentials/BeeminderApi.credentials.ts index 365813f246..ebedb0c224 100644 --- a/packages/nodes-base/credentials/BeeminderApi.credentials.ts +++ b/packages/nodes-base/credentials/BeeminderApi.credentials.ts @@ -7,8 +7,11 @@ import { export class BeeminderApi implements ICredentialType { name = 'beeminderApi'; + displayName = 'Beeminder API'; + documentationUrl = 'beeminder'; + properties: INodeProperties[] = [ { displayName: 'User', diff --git a/packages/nodes-base/credentials/BitbucketApi.credentials.ts b/packages/nodes-base/credentials/BitbucketApi.credentials.ts index 6e1fa5975e..9ba5def5e2 100644 --- a/packages/nodes-base/credentials/BitbucketApi.credentials.ts +++ b/packages/nodes-base/credentials/BitbucketApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BitbucketApi implements ICredentialType { name = 'bitbucketApi'; + displayName = 'Bitbucket API'; + documentationUrl = 'bitbucket'; + properties: INodeProperties[] = [ { displayName: 'Username', diff --git a/packages/nodes-base/credentials/BitlyApi.credentials.ts b/packages/nodes-base/credentials/BitlyApi.credentials.ts index d1420c6f3a..9f6e770f99 100644 --- a/packages/nodes-base/credentials/BitlyApi.credentials.ts +++ b/packages/nodes-base/credentials/BitlyApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BitlyApi implements ICredentialType { name = 'bitlyApi'; + displayName = 'Bitly API'; + documentationUrl = 'bitly'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/BitlyOAuth2Api.credentials.ts b/packages/nodes-base/credentials/BitlyOAuth2Api.credentials.ts index 864ae35d68..d9600794c8 100644 --- a/packages/nodes-base/credentials/BitlyOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/BitlyOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BitlyOAuth2Api implements ICredentialType { name = 'bitlyOAuth2Api'; + displayName = 'Bitly OAuth2 API'; + documentationUrl = 'bitly'; + extends = ['oAuth2Api']; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/BitwardenApi.credentials.ts b/packages/nodes-base/credentials/BitwardenApi.credentials.ts index 53a46f8bcc..73074e4c62 100644 --- a/packages/nodes-base/credentials/BitwardenApi.credentials.ts +++ b/packages/nodes-base/credentials/BitwardenApi.credentials.ts @@ -4,8 +4,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BitwardenApi implements ICredentialType { name = 'bitwardenApi'; + displayName = 'Bitwarden API'; + documentationUrl = 'bitwarden'; + properties: INodeProperties[] = [ { displayName: 'Client ID', diff --git a/packages/nodes-base/credentials/BoxOAuth2Api.credentials.ts b/packages/nodes-base/credentials/BoxOAuth2Api.credentials.ts index 8f46a053c3..0e2d277558 100644 --- a/packages/nodes-base/credentials/BoxOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/BoxOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BoxOAuth2Api implements ICredentialType { name = 'boxOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Box OAuth2 API'; + documentationUrl = 'box'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/BrandfetchApi.credentials.ts b/packages/nodes-base/credentials/BrandfetchApi.credentials.ts index 0786361a80..c20fcd0373 100644 --- a/packages/nodes-base/credentials/BrandfetchApi.credentials.ts +++ b/packages/nodes-base/credentials/BrandfetchApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BrandfetchApi implements ICredentialType { name = 'brandfetchApi'; + displayName = 'Brandfetch API'; + documentationUrl = 'brandfetch'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/BubbleApi.credentials.ts b/packages/nodes-base/credentials/BubbleApi.credentials.ts index eac08a82f3..1997cb0118 100644 --- a/packages/nodes-base/credentials/BubbleApi.credentials.ts +++ b/packages/nodes-base/credentials/BubbleApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class BubbleApi implements ICredentialType { name = 'bubbleApi'; + displayName = 'Bubble API'; + documentationUrl = 'bubble'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/CalApi.credentials.ts b/packages/nodes-base/credentials/CalApi.credentials.ts index 17eb2f3b67..f697098224 100644 --- a/packages/nodes-base/credentials/CalApi.credentials.ts +++ b/packages/nodes-base/credentials/CalApi.credentials.ts @@ -7,8 +7,11 @@ import { export class CalApi implements ICredentialType { name = 'calApi'; + displayName = 'Cal API'; + documentationUrl = 'cal'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/CalendlyApi.credentials.ts b/packages/nodes-base/credentials/CalendlyApi.credentials.ts index a15c13492e..49707444e8 100644 --- a/packages/nodes-base/credentials/CalendlyApi.credentials.ts +++ b/packages/nodes-base/credentials/CalendlyApi.credentials.ts @@ -8,8 +8,11 @@ import { export class CalendlyApi implements ICredentialType { name = 'calendlyApi'; + displayName = 'Calendly API'; + documentationUrl = 'calendly'; + properties: INodeProperties[] = [ // Change name to Personal Access Token once API Keys // are deprecated @@ -21,6 +24,7 @@ export class CalendlyApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -31,7 +35,7 @@ export class CalendlyApi implements ICredentialType { // remove condition once v1 is deprecated // and only inject credentials as an access token if (tokenType === 'accessToken') { - requestOptions.headers!['Authorization'] = `Bearer ${apiKey}`; + requestOptions.headers!.Authorization = `Bearer ${apiKey}`; } else { requestOptions.headers!['X-TOKEN'] = apiKey; } diff --git a/packages/nodes-base/credentials/ChargebeeApi.credentials.ts b/packages/nodes-base/credentials/ChargebeeApi.credentials.ts index 81c8f3fdb5..1e92752050 100644 --- a/packages/nodes-base/credentials/ChargebeeApi.credentials.ts +++ b/packages/nodes-base/credentials/ChargebeeApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ChargebeeApi implements ICredentialType { name = 'chargebeeApi'; + displayName = 'Chargebee API'; + documentationUrl = 'chargebee'; + properties: INodeProperties[] = [ { displayName: 'Account Name', diff --git a/packages/nodes-base/credentials/CircleCiApi.credentials.ts b/packages/nodes-base/credentials/CircleCiApi.credentials.ts index f11600c9bd..3a789b003e 100644 --- a/packages/nodes-base/credentials/CircleCiApi.credentials.ts +++ b/packages/nodes-base/credentials/CircleCiApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class CircleCiApi implements ICredentialType { name = 'circleCiApi'; + displayName = 'CircleCI API'; + documentationUrl = 'circleCi'; + properties: INodeProperties[] = [ { displayName: 'Personal API Token', diff --git a/packages/nodes-base/credentials/CiscoWebexOAuth2Api.credentials.ts b/packages/nodes-base/credentials/CiscoWebexOAuth2Api.credentials.ts index 0c395fd974..37328eb6d9 100644 --- a/packages/nodes-base/credentials/CiscoWebexOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/CiscoWebexOAuth2Api.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class CiscoWebexOAuth2Api implements ICredentialType { name = 'ciscoWebexOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Cisco Webex OAuth2 API'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/CitrixAdcApi.credentials.ts b/packages/nodes-base/credentials/CitrixAdcApi.credentials.ts index 0bd0496b05..07c5cd8984 100644 --- a/packages/nodes-base/credentials/CitrixAdcApi.credentials.ts +++ b/packages/nodes-base/credentials/CitrixAdcApi.credentials.ts @@ -7,8 +7,11 @@ import { export class CitrixAdcApi implements ICredentialType { name = 'citrixAdcApi'; + displayName = 'Citrix ADC API'; + documentationUrl = 'citrix'; + properties: INodeProperties[] = [ { displayName: 'URL', diff --git a/packages/nodes-base/credentials/ClearbitApi.credentials.ts b/packages/nodes-base/credentials/ClearbitApi.credentials.ts index a9a17a55ba..3f8e07b253 100644 --- a/packages/nodes-base/credentials/ClearbitApi.credentials.ts +++ b/packages/nodes-base/credentials/ClearbitApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ClearbitApi implements ICredentialType { name = 'clearbitApi'; + displayName = 'Clearbit API'; + documentationUrl = 'clearbit'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/ClickUpApi.credentials.ts b/packages/nodes-base/credentials/ClickUpApi.credentials.ts index d292ba0a81..7227d12bc1 100644 --- a/packages/nodes-base/credentials/ClickUpApi.credentials.ts +++ b/packages/nodes-base/credentials/ClickUpApi.credentials.ts @@ -7,8 +7,11 @@ import { export class ClickUpApi implements ICredentialType { name = 'clickUpApi'; + displayName = 'ClickUp API'; + documentationUrl = 'clickUp'; + properties: INodeProperties[] = [ { displayName: 'Access Token', @@ -18,6 +21,7 @@ export class ClickUpApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/ClickUpOAuth2Api.credentials.ts b/packages/nodes-base/credentials/ClickUpOAuth2Api.credentials.ts index 50403cc0c0..857e8a4fac 100644 --- a/packages/nodes-base/credentials/ClickUpOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/ClickUpOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ClickUpOAuth2Api implements ICredentialType { name = 'clickUpOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'ClickUp OAuth2 API'; + documentationUrl = 'clickUp'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/ClockifyApi.credentials.ts b/packages/nodes-base/credentials/ClockifyApi.credentials.ts index d8b834a93f..992dea0adb 100644 --- a/packages/nodes-base/credentials/ClockifyApi.credentials.ts +++ b/packages/nodes-base/credentials/ClockifyApi.credentials.ts @@ -7,8 +7,11 @@ import { export class ClockifyApi implements ICredentialType { name = 'clockifyApi'; + displayName = 'Clockify API'; + documentationUrl = 'clockify'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class ClockifyApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class ClockifyApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.clockify.me/api/v1', diff --git a/packages/nodes-base/credentials/CloudflareApi.credentials.ts b/packages/nodes-base/credentials/CloudflareApi.credentials.ts index b15bf48ca7..1844b5945c 100644 --- a/packages/nodes-base/credentials/CloudflareApi.credentials.ts +++ b/packages/nodes-base/credentials/CloudflareApi.credentials.ts @@ -7,8 +7,11 @@ import { export class CloudflareApi implements ICredentialType { name = 'cloudflareApi'; + displayName = 'Cloudflare API'; + documentationUrl = 'cloudflare'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/CockpitApi.credentials.ts b/packages/nodes-base/credentials/CockpitApi.credentials.ts index 30fd2a1fea..a91048ee9e 100644 --- a/packages/nodes-base/credentials/CockpitApi.credentials.ts +++ b/packages/nodes-base/credentials/CockpitApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class CockpitApi implements ICredentialType { name = 'cockpitApi'; + displayName = 'Cockpit API'; + documentationUrl = 'cockpit'; + properties: INodeProperties[] = [ { displayName: 'Cockpit URL', diff --git a/packages/nodes-base/credentials/CodaApi.credentials.ts b/packages/nodes-base/credentials/CodaApi.credentials.ts index 061158f86b..f44179b93c 100644 --- a/packages/nodes-base/credentials/CodaApi.credentials.ts +++ b/packages/nodes-base/credentials/CodaApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class CodaApi implements ICredentialType { name = 'codaApi'; + displayName = 'Coda API'; + documentationUrl = 'coda'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/ContentfulApi.credentials.ts b/packages/nodes-base/credentials/ContentfulApi.credentials.ts index 0b887dd475..a7e7eed743 100644 --- a/packages/nodes-base/credentials/ContentfulApi.credentials.ts +++ b/packages/nodes-base/credentials/ContentfulApi.credentials.ts @@ -3,8 +3,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; //https://www.contentful.com/developers/docs/references/authentication/ export class ContentfulApi implements ICredentialType { name = 'contentfulApi'; + displayName = 'Contenful API'; + documentationUrl = 'contentful'; + properties: INodeProperties[] = [ { displayName: 'Space ID', diff --git a/packages/nodes-base/credentials/ConvertKitApi.credentials.ts b/packages/nodes-base/credentials/ConvertKitApi.credentials.ts index 8854665d16..c498fc7748 100644 --- a/packages/nodes-base/credentials/ConvertKitApi.credentials.ts +++ b/packages/nodes-base/credentials/ConvertKitApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ConvertKitApi implements ICredentialType { name = 'convertKitApi'; + displayName = 'ConvertKit API'; + documentationUrl = 'convertKit'; + properties: INodeProperties[] = [ { displayName: 'API Secret', diff --git a/packages/nodes-base/credentials/CopperApi.credentials.ts b/packages/nodes-base/credentials/CopperApi.credentials.ts index 42fd1b2bc6..54843fe151 100644 --- a/packages/nodes-base/credentials/CopperApi.credentials.ts +++ b/packages/nodes-base/credentials/CopperApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class CopperApi implements ICredentialType { name = 'copperApi'; + displayName = 'Copper API'; + documentationUrl = 'copper'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/CortexApi.credentials.ts b/packages/nodes-base/credentials/CortexApi.credentials.ts index 97c3e1003c..d930d96c19 100644 --- a/packages/nodes-base/credentials/CortexApi.credentials.ts +++ b/packages/nodes-base/credentials/CortexApi.credentials.ts @@ -7,8 +7,11 @@ import { export class CortexApi implements ICredentialType { name = 'cortexApi'; + displayName = 'Cortex API'; + documentationUrl = 'cortex'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/CrateDb.credentials.ts b/packages/nodes-base/credentials/CrateDb.credentials.ts index a1a94ee6d2..7688aa47e5 100644 --- a/packages/nodes-base/credentials/CrateDb.credentials.ts +++ b/packages/nodes-base/credentials/CrateDb.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class CrateDb implements ICredentialType { name = 'crateDb'; + displayName = 'CrateDB'; + documentationUrl = 'crateDb'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/CustomerIoApi.credentials.ts b/packages/nodes-base/credentials/CustomerIoApi.credentials.ts index 63571adff1..50e9c54cd1 100644 --- a/packages/nodes-base/credentials/CustomerIoApi.credentials.ts +++ b/packages/nodes-base/credentials/CustomerIoApi.credentials.ts @@ -7,8 +7,11 @@ import { export class CustomerIoApi implements ICredentialType { name = 'customerIoApi'; + displayName = 'Customer.io API'; + documentationUrl = 'customerIo'; + properties: INodeProperties[] = [ { displayName: 'Tracking API Key', @@ -52,6 +55,7 @@ export class CustomerIoApi implements ICredentialType { description: 'Required for App API', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, diff --git a/packages/nodes-base/credentials/DeepLApi.credentials.ts b/packages/nodes-base/credentials/DeepLApi.credentials.ts index 4f2f015276..36053969a3 100644 --- a/packages/nodes-base/credentials/DeepLApi.credentials.ts +++ b/packages/nodes-base/credentials/DeepLApi.credentials.ts @@ -7,8 +7,11 @@ import { export class DeepLApi implements ICredentialType { name = 'deepLApi'; + displayName = 'DeepL API'; + documentationUrl = 'deepL'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/DemioApi.credentials.ts b/packages/nodes-base/credentials/DemioApi.credentials.ts index a1494c5278..36d7e89c32 100644 --- a/packages/nodes-base/credentials/DemioApi.credentials.ts +++ b/packages/nodes-base/credentials/DemioApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class DemioApi implements ICredentialType { name = 'demioApi'; + displayName = 'Demio API'; + documentationUrl = 'demio'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/DhlApi.credentials.ts b/packages/nodes-base/credentials/DhlApi.credentials.ts index 994f944226..6fbc8fea05 100644 --- a/packages/nodes-base/credentials/DhlApi.credentials.ts +++ b/packages/nodes-base/credentials/DhlApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class DhlApi implements ICredentialType { name = 'dhlApi'; + displayName = 'DHL API'; + documentationUrl = 'dhl'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/DiscourseApi.credentials.ts b/packages/nodes-base/credentials/DiscourseApi.credentials.ts index 0f61c710ad..1be0010023 100644 --- a/packages/nodes-base/credentials/DiscourseApi.credentials.ts +++ b/packages/nodes-base/credentials/DiscourseApi.credentials.ts @@ -8,8 +8,11 @@ import { export class DiscourseApi implements ICredentialType { name = 'discourseApi'; + displayName = 'Discourse API'; + documentationUrl = 'discourse'; + properties: INodeProperties[] = [ { displayName: 'URL', diff --git a/packages/nodes-base/credentials/DisqusApi.credentials.ts b/packages/nodes-base/credentials/DisqusApi.credentials.ts index 5afe35a161..e7c8cc484d 100644 --- a/packages/nodes-base/credentials/DisqusApi.credentials.ts +++ b/packages/nodes-base/credentials/DisqusApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class DisqusApi implements ICredentialType { name = 'disqusApi'; + displayName = 'Disqus API'; + documentationUrl = 'disqus'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/DriftApi.credentials.ts b/packages/nodes-base/credentials/DriftApi.credentials.ts index ef01946452..004201ee7f 100644 --- a/packages/nodes-base/credentials/DriftApi.credentials.ts +++ b/packages/nodes-base/credentials/DriftApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class DriftApi implements ICredentialType { name = 'driftApi'; + displayName = 'Drift API'; + documentationUrl = 'drift'; + properties: INodeProperties[] = [ { displayName: 'Personal Access Token', diff --git a/packages/nodes-base/credentials/DriftOAuth2Api.credentials.ts b/packages/nodes-base/credentials/DriftOAuth2Api.credentials.ts index bb8c35e5bf..8a37ad68b5 100644 --- a/packages/nodes-base/credentials/DriftOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/DriftOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class DriftOAuth2Api implements ICredentialType { name = 'driftOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Drift OAuth2 API'; + documentationUrl = 'drift'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/DropboxApi.credentials.ts b/packages/nodes-base/credentials/DropboxApi.credentials.ts index f92e5f3bb9..8a1b78a436 100644 --- a/packages/nodes-base/credentials/DropboxApi.credentials.ts +++ b/packages/nodes-base/credentials/DropboxApi.credentials.ts @@ -7,8 +7,11 @@ import { export class DropboxApi implements ICredentialType { name = 'dropboxApi'; + displayName = 'Dropbox API'; + documentationUrl = 'dropbox'; + properties: INodeProperties[] = [ { displayName: 'Access Token', @@ -34,6 +37,7 @@ export class DropboxApi implements ICredentialType { default: 'full', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/DropboxOAuth2Api.credentials.ts b/packages/nodes-base/credentials/DropboxOAuth2Api.credentials.ts index bf1127ee86..0ed16239b0 100644 --- a/packages/nodes-base/credentials/DropboxOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/DropboxOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['files.content.write', 'files.content.read', 'sharing.read', 'ac export class DropboxOAuth2Api implements ICredentialType { name = 'dropboxOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Dropbox OAuth2 API'; + documentationUrl = 'dropbox'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/DropcontactApi.credentials.ts b/packages/nodes-base/credentials/DropcontactApi.credentials.ts index 7f9307e8a3..2ddab6136a 100644 --- a/packages/nodes-base/credentials/DropcontactApi.credentials.ts +++ b/packages/nodes-base/credentials/DropcontactApi.credentials.ts @@ -7,8 +7,11 @@ import { export class DropcontactApi implements ICredentialType { name = 'dropcontactApi'; + displayName = 'Dropcontact API'; + documentationUrl = 'dropcontact'; + properties = [ { displayName: 'API Key', @@ -17,6 +20,7 @@ export class DropcontactApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class DropcontactApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.dropcontact.io', diff --git a/packages/nodes-base/credentials/ERPNextApi.credentials.ts b/packages/nodes-base/credentials/ERPNextApi.credentials.ts index 99b5269523..75b263e177 100644 --- a/packages/nodes-base/credentials/ERPNextApi.credentials.ts +++ b/packages/nodes-base/credentials/ERPNextApi.credentials.ts @@ -7,8 +7,11 @@ import { export class ERPNextApi implements ICredentialType { name = 'erpNextApi'; + displayName = 'ERPNext API'; + documentationUrl = 'erpnext'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -74,6 +77,7 @@ export class ERPNextApi implements ICredentialType { default: false, }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -82,6 +86,7 @@ export class ERPNextApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: diff --git a/packages/nodes-base/credentials/EgoiApi.credentials.ts b/packages/nodes-base/credentials/EgoiApi.credentials.ts index 3ec9aaff17..20e3bb133f 100644 --- a/packages/nodes-base/credentials/EgoiApi.credentials.ts +++ b/packages/nodes-base/credentials/EgoiApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class EgoiApi implements ICredentialType { name = 'egoiApi'; - displayName = 'E-goi API'; + + displayName = 'E-Goi API'; + documentationUrl = 'egoi'; + properties: INodeProperties[] = [ // The credentials to get from user and save encrypted. // Properties can be defined exactly in the same way diff --git a/packages/nodes-base/credentials/ElasticSecurityApi.credentials.ts b/packages/nodes-base/credentials/ElasticSecurityApi.credentials.ts index ed4f832984..e941f89eef 100644 --- a/packages/nodes-base/credentials/ElasticSecurityApi.credentials.ts +++ b/packages/nodes-base/credentials/ElasticSecurityApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ElasticSecurityApi implements ICredentialType { name = 'elasticSecurityApi'; + displayName = 'Elastic Security API'; + documentationUrl = 'elasticSecurity'; + properties: INodeProperties[] = [ { displayName: 'Username', diff --git a/packages/nodes-base/credentials/ElasticsearchApi.credentials.ts b/packages/nodes-base/credentials/ElasticsearchApi.credentials.ts index 5b585b545d..4377c5ab36 100644 --- a/packages/nodes-base/credentials/ElasticsearchApi.credentials.ts +++ b/packages/nodes-base/credentials/ElasticsearchApi.credentials.ts @@ -7,8 +7,11 @@ import { export class ElasticsearchApi implements ICredentialType { name = 'elasticsearchApi'; + displayName = 'Elasticsearch API'; + documentationUrl = 'elasticsearch'; + properties: INodeProperties[] = [ { displayName: 'Username', diff --git a/packages/nodes-base/credentials/EmeliaApi.credentials.ts b/packages/nodes-base/credentials/EmeliaApi.credentials.ts index 026c931c66..473fd33e92 100644 --- a/packages/nodes-base/credentials/EmeliaApi.credentials.ts +++ b/packages/nodes-base/credentials/EmeliaApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class EmeliaApi implements ICredentialType { name = 'emeliaApi'; + displayName = 'Emelia API'; + documentationUrl = 'emelia'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/EventbriteApi.credentials.ts b/packages/nodes-base/credentials/EventbriteApi.credentials.ts index 3c5a9aa345..af7b91fe68 100644 --- a/packages/nodes-base/credentials/EventbriteApi.credentials.ts +++ b/packages/nodes-base/credentials/EventbriteApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class EventbriteApi implements ICredentialType { name = 'eventbriteApi'; + displayName = 'Eventbrite API'; + documentationUrl = 'eventbrite'; + properties: INodeProperties[] = [ { displayName: 'Private Key', diff --git a/packages/nodes-base/credentials/EventbriteOAuth2Api.credentials.ts b/packages/nodes-base/credentials/EventbriteOAuth2Api.credentials.ts index e8f8dfd2ae..88c609f558 100644 --- a/packages/nodes-base/credentials/EventbriteOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/EventbriteOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class EventbriteOAuth2Api implements ICredentialType { name = 'eventbriteOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Eventbrite OAuth2 API'; + documentationUrl = 'eventbrite'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/FacebookGraphApi.credentials.ts b/packages/nodes-base/credentials/FacebookGraphApi.credentials.ts index edf6dc1e31..2832b72dce 100644 --- a/packages/nodes-base/credentials/FacebookGraphApi.credentials.ts +++ b/packages/nodes-base/credentials/FacebookGraphApi.credentials.ts @@ -7,8 +7,11 @@ import { export class FacebookGraphApi implements ICredentialType { name = 'facebookGraphApi'; + displayName = 'Facebook Graph API'; + documentationUrl = 'facebookGraph'; + properties: INodeProperties[] = [ { displayName: 'Access Token', @@ -18,6 +21,7 @@ export class FacebookGraphApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class FacebookGraphApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://graph.facebook.com/v8.0', diff --git a/packages/nodes-base/credentials/FacebookGraphAppApi.credentials.ts b/packages/nodes-base/credentials/FacebookGraphAppApi.credentials.ts index 74478d176a..b48b9b3352 100644 --- a/packages/nodes-base/credentials/FacebookGraphAppApi.credentials.ts +++ b/packages/nodes-base/credentials/FacebookGraphAppApi.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class FacebookGraphAppApi implements ICredentialType { name = 'facebookGraphAppApi'; + displayName = 'Facebook Graph API (App)'; + documentationUrl = 'facebookGraphApp'; + extends = ['facebookGraphApi']; + properties: INodeProperties[] = [ { displayName: 'App Secret', diff --git a/packages/nodes-base/credentials/FigmaApi.credentials.ts b/packages/nodes-base/credentials/FigmaApi.credentials.ts index 83d504f91f..fd5518affe 100644 --- a/packages/nodes-base/credentials/FigmaApi.credentials.ts +++ b/packages/nodes-base/credentials/FigmaApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class FigmaApi implements ICredentialType { name = 'figmaApi'; + displayName = 'Figma API'; + documentationUrl = 'figma'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/FileMaker.credentials.ts b/packages/nodes-base/credentials/FileMaker.credentials.ts index 2c82c8c059..a93898a020 100644 --- a/packages/nodes-base/credentials/FileMaker.credentials.ts +++ b/packages/nodes-base/credentials/FileMaker.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class FileMaker implements ICredentialType { name = 'fileMaker'; + displayName = 'FileMaker API'; + documentationUrl = 'fileMaker'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/FlowApi.credentials.ts b/packages/nodes-base/credentials/FlowApi.credentials.ts index 98872eb8f1..fe94c57b42 100644 --- a/packages/nodes-base/credentials/FlowApi.credentials.ts +++ b/packages/nodes-base/credentials/FlowApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class FlowApi implements ICredentialType { name = 'flowApi'; + displayName = 'Flow API'; + documentationUrl = 'flow'; + properties: INodeProperties[] = [ { displayName: 'Organization ID', diff --git a/packages/nodes-base/credentials/FormIoApi.credentials.ts b/packages/nodes-base/credentials/FormIoApi.credentials.ts index 1150b87453..90c5bc0279 100644 --- a/packages/nodes-base/credentials/FormIoApi.credentials.ts +++ b/packages/nodes-base/credentials/FormIoApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class FormIoApi implements ICredentialType { name = 'formIoApi'; + displayName = 'Form.io API'; + documentationUrl = 'formIoTrigger'; + properties: INodeProperties[] = [ { displayName: 'Environment', diff --git a/packages/nodes-base/credentials/FormstackApi.credentials.ts b/packages/nodes-base/credentials/FormstackApi.credentials.ts index 1409cd1f59..38b1bac215 100644 --- a/packages/nodes-base/credentials/FormstackApi.credentials.ts +++ b/packages/nodes-base/credentials/FormstackApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class FormstackApi implements ICredentialType { name = 'formstackApi'; + displayName = 'Formstack API'; + documentationUrl = 'formstackTrigger'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/FormstackOAuth2Api.credentials.ts b/packages/nodes-base/credentials/FormstackOAuth2Api.credentials.ts index 80da532873..90791a3f46 100644 --- a/packages/nodes-base/credentials/FormstackOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/FormstackOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes: string[] = []; export class FormstackOAuth2Api implements ICredentialType { name = 'formstackOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Formstack OAuth2 API'; + documentationUrl = 'formstackTrigger'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/FreshdeskApi.credentials.ts b/packages/nodes-base/credentials/FreshdeskApi.credentials.ts index 31614cdac8..dd2150611a 100644 --- a/packages/nodes-base/credentials/FreshdeskApi.credentials.ts +++ b/packages/nodes-base/credentials/FreshdeskApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class FreshdeskApi implements ICredentialType { name = 'freshdeskApi'; + displayName = 'Freshdesk API'; + documentationUrl = 'freshdesk'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/FreshserviceApi.credentials.ts b/packages/nodes-base/credentials/FreshserviceApi.credentials.ts index e32e9361af..c80e791948 100644 --- a/packages/nodes-base/credentials/FreshserviceApi.credentials.ts +++ b/packages/nodes-base/credentials/FreshserviceApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class FreshserviceApi implements ICredentialType { name = 'freshserviceApi'; + displayName = 'Freshservice API'; + documentationUrl = 'freshservice'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/FreshworksCrmApi.credentials.ts b/packages/nodes-base/credentials/FreshworksCrmApi.credentials.ts index 0addd7fcb1..727995a33e 100644 --- a/packages/nodes-base/credentials/FreshworksCrmApi.credentials.ts +++ b/packages/nodes-base/credentials/FreshworksCrmApi.credentials.ts @@ -7,8 +7,11 @@ import { export class FreshworksCrmApi implements ICredentialType { name = 'freshworksCrmApi'; + displayName = 'Freshworks CRM API'; + documentationUrl = 'freshdesk'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -28,6 +31,7 @@ export class FreshworksCrmApi implements ICredentialType { 'Domain in the Freshworks CRM org URL. For example, in https://n8n-org.myfreshworks.com, the domain is n8n-org.', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -36,6 +40,7 @@ export class FreshworksCrmApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '=https://{{$credentials?.domain}}.myfreshworks.com/crm/sales/api', diff --git a/packages/nodes-base/credentials/Ftp.credentials.ts b/packages/nodes-base/credentials/Ftp.credentials.ts index cd0dff7a9d..ba8cdbd41d 100644 --- a/packages/nodes-base/credentials/Ftp.credentials.ts +++ b/packages/nodes-base/credentials/Ftp.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Ftp implements ICredentialType { name = 'ftp'; + displayName = 'FTP'; + documentationUrl = 'ftp'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/GSuiteAdminOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GSuiteAdminOAuth2Api.credentials.ts index 44a5a15712..a843f7c0c0 100644 --- a/packages/nodes-base/credentials/GSuiteAdminOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GSuiteAdminOAuth2Api.credentials.ts @@ -9,9 +9,13 @@ const scopes = [ export class GSuiteAdminOAuth2Api implements ICredentialType { name = 'gSuiteAdminOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Workspace Admin OAuth2 API'; + documentationUrl = 'google'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GetResponseApi.credentials.ts b/packages/nodes-base/credentials/GetResponseApi.credentials.ts index c5ccb7d6da..79c4509ce7 100644 --- a/packages/nodes-base/credentials/GetResponseApi.credentials.ts +++ b/packages/nodes-base/credentials/GetResponseApi.credentials.ts @@ -7,8 +7,11 @@ import { export class GetResponseApi implements ICredentialType { name = 'getResponseApi'; + displayName = 'GetResponse API'; + documentationUrl = 'getResponse'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class GetResponseApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class GetResponseApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.getresponse.com/v3', diff --git a/packages/nodes-base/credentials/GetResponseOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GetResponseOAuth2Api.credentials.ts index a80aad370c..e8beb7ef00 100644 --- a/packages/nodes-base/credentials/GetResponseOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GetResponseOAuth2Api.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GetResponseOAuth2Api implements ICredentialType { name = 'getResponseOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'GetResponse OAuth2 API'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/GhostAdminApi.credentials.ts b/packages/nodes-base/credentials/GhostAdminApi.credentials.ts index 4c6a25870a..2d3b50c58c 100644 --- a/packages/nodes-base/credentials/GhostAdminApi.credentials.ts +++ b/packages/nodes-base/credentials/GhostAdminApi.credentials.ts @@ -9,8 +9,11 @@ import { import jwt from 'jsonwebtoken'; export class GhostAdminApi implements ICredentialType { name = 'ghostAdminApi'; + displayName = 'Ghost Admin API'; + documentationUrl = 'ghost'; + properties: INodeProperties[] = [ { displayName: 'URL', diff --git a/packages/nodes-base/credentials/GhostContentApi.credentials.ts b/packages/nodes-base/credentials/GhostContentApi.credentials.ts index 7708475390..ff2d310a3b 100644 --- a/packages/nodes-base/credentials/GhostContentApi.credentials.ts +++ b/packages/nodes-base/credentials/GhostContentApi.credentials.ts @@ -8,8 +8,11 @@ import { export class GhostContentApi implements ICredentialType { name = 'ghostContentApi'; + displayName = 'Ghost Content API'; + documentationUrl = 'ghost'; + properties: INodeProperties[] = [ { displayName: 'URL', @@ -26,6 +29,7 @@ export class GhostContentApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -36,6 +40,7 @@ export class GhostContentApi implements ICredentialType { }; return requestOptions; } + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials.url}}', diff --git a/packages/nodes-base/credentials/GitPassword.credentials.ts b/packages/nodes-base/credentials/GitPassword.credentials.ts index b8739a35d5..5b5d2653e3 100644 --- a/packages/nodes-base/credentials/GitPassword.credentials.ts +++ b/packages/nodes-base/credentials/GitPassword.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GitPassword implements ICredentialType { name = 'gitPassword'; + displayName = 'Git'; + documentationUrl = 'git'; + properties: INodeProperties[] = [ { displayName: 'Username', diff --git a/packages/nodes-base/credentials/GithubApi.credentials.ts b/packages/nodes-base/credentials/GithubApi.credentials.ts index 611d53ac6f..cc77f91105 100644 --- a/packages/nodes-base/credentials/GithubApi.credentials.ts +++ b/packages/nodes-base/credentials/GithubApi.credentials.ts @@ -7,8 +7,11 @@ import { export class GithubApi implements ICredentialType { name = 'githubApi'; + displayName = 'GitHub API'; + documentationUrl = 'github'; + properties: INodeProperties[] = [ { displayName: 'Github Server', diff --git a/packages/nodes-base/credentials/GithubOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GithubOAuth2Api.credentials.ts index 5f273a3bc7..0936d0070c 100644 --- a/packages/nodes-base/credentials/GithubOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GithubOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GithubOAuth2Api implements ICredentialType { name = 'githubOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'GitHub OAuth2 API'; + documentationUrl = 'github'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/GitlabApi.credentials.ts b/packages/nodes-base/credentials/GitlabApi.credentials.ts index 44eeb71321..a99703b719 100644 --- a/packages/nodes-base/credentials/GitlabApi.credentials.ts +++ b/packages/nodes-base/credentials/GitlabApi.credentials.ts @@ -7,8 +7,11 @@ import { export class GitlabApi implements ICredentialType { name = 'gitlabApi'; + displayName = 'GitLab API'; + documentationUrl = 'gitlab'; + properties: INodeProperties[] = [ { displayName: 'Gitlab Server', @@ -24,6 +27,7 @@ export class GitlabApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/GitlabOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GitlabOAuth2Api.credentials.ts index 93a069a978..4136f37676 100644 --- a/packages/nodes-base/credentials/GitlabOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GitlabOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GitlabOAuth2Api implements ICredentialType { name = 'gitlabOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'GitLab OAuth2 API'; + documentationUrl = 'gitlab'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/GmailOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GmailOAuth2Api.credentials.ts index e00cad6c52..a716895604 100644 --- a/packages/nodes-base/credentials/GmailOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GmailOAuth2Api.credentials.ts @@ -11,9 +11,13 @@ const scopes = [ export class GmailOAuth2Api implements ICredentialType { name = 'gmailOAuth2'; + extends = ['googleOAuth2Api']; + displayName = 'Gmail OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoToWebinarOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoToWebinarOAuth2Api.credentials.ts index a4280a56f1..e6cf7d8595 100644 --- a/packages/nodes-base/credentials/GoToWebinarOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoToWebinarOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GoToWebinarOAuth2Api implements ICredentialType { name = 'goToWebinarOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'GoToWebinar OAuth2 API'; + documentationUrl = 'goToWebinar'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/GoogleAdsOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleAdsOAuth2Api.credentials.ts index 44edcd7836..5f7860c716 100644 --- a/packages/nodes-base/credentials/GoogleAdsOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleAdsOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['https://www.googleapis.com/auth/adwords']; export class GoogleAdsOAuth2Api implements ICredentialType { name = 'googleAdsOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Ads OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Developer Token', diff --git a/packages/nodes-base/credentials/GoogleAnalyticsOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleAnalyticsOAuth2Api.credentials.ts index 4092ab9474..523d518234 100644 --- a/packages/nodes-base/credentials/GoogleAnalyticsOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleAnalyticsOAuth2Api.credentials.ts @@ -7,9 +7,13 @@ const scopes = [ export class GoogleAnalyticsOAuth2Api implements ICredentialType { name = 'googleAnalyticsOAuth2'; + extends = ['googleOAuth2Api']; + displayName = 'Google Analytics OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleApi.credentials.ts b/packages/nodes-base/credentials/GoogleApi.credentials.ts index 07e5446472..dea436c789 100644 --- a/packages/nodes-base/credentials/GoogleApi.credentials.ts +++ b/packages/nodes-base/credentials/GoogleApi.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GoogleApi implements ICredentialType { name = 'googleApi'; + displayName = 'Google API'; + documentationUrl = 'google/service-account'; + icon = 'file:Google.svg'; + properties: INodeProperties[] = [ { displayName: 'Service Account Email', diff --git a/packages/nodes-base/credentials/GoogleBigQueryOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleBigQueryOAuth2Api.credentials.ts index 64c59e108d..ffcfadca97 100644 --- a/packages/nodes-base/credentials/GoogleBigQueryOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleBigQueryOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['https://www.googleapis.com/auth/bigquery']; export class GoogleBigQueryOAuth2Api implements ICredentialType { name = 'googleBigQueryOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google BigQuery OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleBooksOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleBooksOAuth2Api.credentials.ts index 69938bba1a..cedab2f6a1 100644 --- a/packages/nodes-base/credentials/GoogleBooksOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleBooksOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['https://www.googleapis.com/auth/books']; export class GoogleBooksOAuth2Api implements ICredentialType { name = 'googleBooksOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Books OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleCalendarOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleCalendarOAuth2Api.credentials.ts index c4c114a6b0..4d958c7a99 100644 --- a/packages/nodes-base/credentials/GoogleCalendarOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleCalendarOAuth2Api.credentials.ts @@ -7,9 +7,13 @@ const scopes = [ export class GoogleCalendarOAuth2Api implements ICredentialType { name = 'googleCalendarOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Calendar OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleCloudNaturalLanguageOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleCloudNaturalLanguageOAuth2Api.credentials.ts index 9f6b43af46..797881e1cc 100644 --- a/packages/nodes-base/credentials/GoogleCloudNaturalLanguageOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleCloudNaturalLanguageOAuth2Api.credentials.ts @@ -7,9 +7,13 @@ const scopes = [ export class GoogleCloudNaturalLanguageOAuth2Api implements ICredentialType { name = 'googleCloudNaturalLanguageOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Cloud Natural Language OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleCloudStorageOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleCloudStorageOAuth2Api.credentials.ts index 0267c6a101..4139615fab 100644 --- a/packages/nodes-base/credentials/GoogleCloudStorageOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleCloudStorageOAuth2Api.credentials.ts @@ -10,9 +10,13 @@ const scopes = [ export class GoogleCloudStorageOAuth2Api implements ICredentialType { name = 'googleCloudStorageOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Cloud Storage OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleContactsOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleContactsOAuth2Api.credentials.ts index 94f1850d17..95f4ebe705 100644 --- a/packages/nodes-base/credentials/GoogleContactsOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleContactsOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['https://www.googleapis.com/auth/contacts']; export class GoogleContactsOAuth2Api implements ICredentialType { name = 'googleContactsOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Contacts OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleDocsOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleDocsOAuth2Api.credentials.ts index 919681e9ec..d03049ca5e 100644 --- a/packages/nodes-base/credentials/GoogleDocsOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleDocsOAuth2Api.credentials.ts @@ -8,9 +8,13 @@ const scopes = [ export class GoogleDocsOAuth2Api implements ICredentialType { name = 'googleDocsOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Docs OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleDriveOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleDriveOAuth2Api.credentials.ts index c1bb2675df..9878212b5b 100644 --- a/packages/nodes-base/credentials/GoogleDriveOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleDriveOAuth2Api.credentials.ts @@ -8,9 +8,13 @@ const scopes = [ export class GoogleDriveOAuth2Api implements ICredentialType { name = 'googleDriveOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Drive OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleFirebaseCloudFirestoreOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleFirebaseCloudFirestoreOAuth2Api.credentials.ts index 9317deed68..decd1f2a49 100644 --- a/packages/nodes-base/credentials/GoogleFirebaseCloudFirestoreOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleFirebaseCloudFirestoreOAuth2Api.credentials.ts @@ -7,9 +7,13 @@ const scopes = [ export class GoogleFirebaseCloudFirestoreOAuth2Api implements ICredentialType { name = 'googleFirebaseCloudFirestoreOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Firebase Cloud Firestore OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleFirebaseRealtimeDatabaseOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleFirebaseRealtimeDatabaseOAuth2Api.credentials.ts index 03de82a411..2b3fae8c84 100644 --- a/packages/nodes-base/credentials/GoogleFirebaseRealtimeDatabaseOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleFirebaseRealtimeDatabaseOAuth2Api.credentials.ts @@ -8,9 +8,13 @@ const scopes = [ export class GoogleFirebaseRealtimeDatabaseOAuth2Api implements ICredentialType { name = 'googleFirebaseRealtimeDatabaseOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Firebase Realtime Database OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleOAuth2Api.credentials.ts index b5718d6d8a..40131946d5 100644 --- a/packages/nodes-base/credentials/GoogleOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleOAuth2Api.credentials.ts @@ -2,10 +2,15 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GoogleOAuth2Api implements ICredentialType { name = 'googleOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Google OAuth2 API'; + documentationUrl = 'google/oauth-generic/'; + icon = 'file:Google.svg'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/GooglePerspectiveOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GooglePerspectiveOAuth2Api.credentials.ts index 3887a85f76..07d9e0e9f3 100644 --- a/packages/nodes-base/credentials/GooglePerspectiveOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GooglePerspectiveOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['https://www.googleapis.com/auth/userinfo.email']; export class GooglePerspectiveOAuth2Api implements ICredentialType { name = 'googlePerspectiveOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Perspective OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleSheetsOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleSheetsOAuth2Api.credentials.ts index 578cb4f752..af9bac2d57 100644 --- a/packages/nodes-base/credentials/GoogleSheetsOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleSheetsOAuth2Api.credentials.ts @@ -8,9 +8,13 @@ const scopes = [ export class GoogleSheetsOAuth2Api implements ICredentialType { name = 'googleSheetsOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Sheets OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleSlidesOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleSlidesOAuth2Api.credentials.ts index 98dc395036..79d9a80a95 100644 --- a/packages/nodes-base/credentials/GoogleSlidesOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleSlidesOAuth2Api.credentials.ts @@ -7,9 +7,13 @@ const scopes = [ export class GoogleSlidesOAuth2Api implements ICredentialType { name = 'googleSlidesOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Slides OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleTasksOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleTasksOAuth2Api.credentials.ts index 678b01e6a1..f3fc37e634 100644 --- a/packages/nodes-base/credentials/GoogleTasksOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleTasksOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['https://www.googleapis.com/auth/tasks']; export class GoogleTasksOAuth2Api implements ICredentialType { name = 'googleTasksOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Tasks OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GoogleTranslateOAuth2Api.credentials.ts b/packages/nodes-base/credentials/GoogleTranslateOAuth2Api.credentials.ts index f4a4ff8e55..60b2eda02b 100644 --- a/packages/nodes-base/credentials/GoogleTranslateOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/GoogleTranslateOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['https://www.googleapis.com/auth/cloud-translation']; export class GoogleTranslateOAuth2Api implements ICredentialType { name = 'googleTranslateOAuth2Api'; + extends = ['googleOAuth2Api']; + displayName = 'Google Translate OAuth2 API'; + documentationUrl = 'google/oauth-single-service'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/GotifyApi.credentials.ts b/packages/nodes-base/credentials/GotifyApi.credentials.ts index 53b500ccce..675be13813 100644 --- a/packages/nodes-base/credentials/GotifyApi.credentials.ts +++ b/packages/nodes-base/credentials/GotifyApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GotifyApi implements ICredentialType { name = 'gotifyApi'; + displayName = 'Gotify API'; + documentationUrl = 'gotify'; + properties: INodeProperties[] = [ { displayName: 'App API Token', diff --git a/packages/nodes-base/credentials/GrafanaApi.credentials.ts b/packages/nodes-base/credentials/GrafanaApi.credentials.ts index c6a1a69a81..714d790a10 100644 --- a/packages/nodes-base/credentials/GrafanaApi.credentials.ts +++ b/packages/nodes-base/credentials/GrafanaApi.credentials.ts @@ -7,8 +7,11 @@ import { export class GrafanaApi implements ICredentialType { name = 'grafanaApi'; + displayName = 'Grafana API'; + documentationUrl = 'grafana'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -28,6 +31,7 @@ export class GrafanaApi implements ICredentialType { required: true, }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/GristApi.credentials.ts b/packages/nodes-base/credentials/GristApi.credentials.ts index b315eb1f19..e8a25ad4d3 100644 --- a/packages/nodes-base/credentials/GristApi.credentials.ts +++ b/packages/nodes-base/credentials/GristApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GristApi implements ICredentialType { name = 'gristApi'; + displayName = 'Grist API'; + documentationUrl = 'grist'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/GumroadApi.credentials.ts b/packages/nodes-base/credentials/GumroadApi.credentials.ts index 462e436ea2..9dad344216 100644 --- a/packages/nodes-base/credentials/GumroadApi.credentials.ts +++ b/packages/nodes-base/credentials/GumroadApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class GumroadApi implements ICredentialType { name = 'gumroadApi'; + displayName = 'Gumroad API'; + documentationUrl = 'gumroad'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/HaloPSAApi.credentials.ts b/packages/nodes-base/credentials/HaloPSAApi.credentials.ts index 65b4d14584..12485fd0f2 100644 --- a/packages/nodes-base/credentials/HaloPSAApi.credentials.ts +++ b/packages/nodes-base/credentials/HaloPSAApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HaloPSAApi implements ICredentialType { name = 'haloPSAApi'; + displayName = 'HaloPSA API'; + documentationUrl = 'halopsa'; + properties: INodeProperties[] = [ { displayName: 'Hosting Type', diff --git a/packages/nodes-base/credentials/HarvestApi.credentials.ts b/packages/nodes-base/credentials/HarvestApi.credentials.ts index a9a9e5da7f..d807e45cf1 100644 --- a/packages/nodes-base/credentials/HarvestApi.credentials.ts +++ b/packages/nodes-base/credentials/HarvestApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HarvestApi implements ICredentialType { name = 'harvestApi'; + displayName = 'Harvest API'; + documentationUrl = 'harvest'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/HarvestOAuth2Api.credentials.ts b/packages/nodes-base/credentials/HarvestOAuth2Api.credentials.ts index cc71987f8c..f8e97421cc 100644 --- a/packages/nodes-base/credentials/HarvestOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/HarvestOAuth2Api.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HarvestOAuth2Api implements ICredentialType { name = 'harvestOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Harvest OAuth2 API'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/HelpScoutOAuth2Api.credentials.ts b/packages/nodes-base/credentials/HelpScoutOAuth2Api.credentials.ts index 2073d3b8df..48d844cb94 100644 --- a/packages/nodes-base/credentials/HelpScoutOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/HelpScoutOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HelpScoutOAuth2Api implements ICredentialType { name = 'helpScoutOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'HelpScout OAuth2 API'; + documentationUrl = 'helpScout'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/HighLevelApi.credentials.ts b/packages/nodes-base/credentials/HighLevelApi.credentials.ts index c7301cc206..c1b9f1683f 100644 --- a/packages/nodes-base/credentials/HighLevelApi.credentials.ts +++ b/packages/nodes-base/credentials/HighLevelApi.credentials.ts @@ -7,8 +7,11 @@ import { export class HighLevelApi implements ICredentialType { name = 'highLevelApi'; + displayName = 'HighLevel API'; + documentationUrl = 'highLevel'; + properties = [ { displayName: 'API Key', @@ -17,6 +20,7 @@ export class HighLevelApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -25,6 +29,7 @@ export class HighLevelApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://rest.gohighlevel.com/v1', diff --git a/packages/nodes-base/credentials/HomeAssistantApi.credentials.ts b/packages/nodes-base/credentials/HomeAssistantApi.credentials.ts index 130e886cb2..48a0230d7a 100644 --- a/packages/nodes-base/credentials/HomeAssistantApi.credentials.ts +++ b/packages/nodes-base/credentials/HomeAssistantApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HomeAssistantApi implements ICredentialType { name = 'homeAssistantApi'; + displayName = 'Home Assistant API'; + documentationUrl = 'homeAssistant'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/HttpBasicAuth.credentials.ts b/packages/nodes-base/credentials/HttpBasicAuth.credentials.ts index 2e3355bbd2..ee70e37f8e 100644 --- a/packages/nodes-base/credentials/HttpBasicAuth.credentials.ts +++ b/packages/nodes-base/credentials/HttpBasicAuth.credentials.ts @@ -2,10 +2,15 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HttpBasicAuth implements ICredentialType { name = 'httpBasicAuth'; + displayName = 'Basic Auth'; + documentationUrl = 'httpRequest'; + genericAuth = true; + icon = 'node:n8n-nodes-base.httpRequest'; + properties: INodeProperties[] = [ { displayName: 'User', diff --git a/packages/nodes-base/credentials/HttpDigestAuth.credentials.ts b/packages/nodes-base/credentials/HttpDigestAuth.credentials.ts index cd2b2b2535..6fe029bb65 100644 --- a/packages/nodes-base/credentials/HttpDigestAuth.credentials.ts +++ b/packages/nodes-base/credentials/HttpDigestAuth.credentials.ts @@ -2,10 +2,15 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HttpDigestAuth implements ICredentialType { name = 'httpDigestAuth'; + displayName = 'Digest Auth'; + documentationUrl = 'httpRequest'; + genericAuth = true; + icon = 'node:n8n-nodes-base.httpRequest'; + properties: INodeProperties[] = [ { displayName: 'User', diff --git a/packages/nodes-base/credentials/HttpHeaderAuth.credentials.ts b/packages/nodes-base/credentials/HttpHeaderAuth.credentials.ts index cad5a36c2c..ddd44544ca 100644 --- a/packages/nodes-base/credentials/HttpHeaderAuth.credentials.ts +++ b/packages/nodes-base/credentials/HttpHeaderAuth.credentials.ts @@ -2,10 +2,15 @@ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-work export class HttpHeaderAuth implements ICredentialType { name = 'httpHeaderAuth'; + displayName = 'Header Auth'; + documentationUrl = 'httpRequest'; + genericAuth = true; + icon = 'node:n8n-nodes-base.httpRequest'; + properties: INodeProperties[] = [ { displayName: 'Name', diff --git a/packages/nodes-base/credentials/HttpQueryAuth.credentials.ts b/packages/nodes-base/credentials/HttpQueryAuth.credentials.ts index 1d085a4af8..ee1d2b7821 100644 --- a/packages/nodes-base/credentials/HttpQueryAuth.credentials.ts +++ b/packages/nodes-base/credentials/HttpQueryAuth.credentials.ts @@ -2,10 +2,15 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HttpQueryAuth implements ICredentialType { name = 'httpQueryAuth'; + displayName = 'Query Auth'; + documentationUrl = 'httpRequest'; + genericAuth = true; + icon = 'node:n8n-nodes-base.httpRequest'; + properties: INodeProperties[] = [ { displayName: 'Name', diff --git a/packages/nodes-base/credentials/HubspotApi.credentials.ts b/packages/nodes-base/credentials/HubspotApi.credentials.ts index 162f7ee24f..45f3969ffd 100644 --- a/packages/nodes-base/credentials/HubspotApi.credentials.ts +++ b/packages/nodes-base/credentials/HubspotApi.credentials.ts @@ -7,8 +7,11 @@ import { export class HubspotApi implements ICredentialType { name = 'hubspotApi'; + displayName = 'HubSpot API'; + documentationUrl = 'hubspot'; + properties: INodeProperties[] = [ { displayName: diff --git a/packages/nodes-base/credentials/HubspotAppToken.credentials.ts b/packages/nodes-base/credentials/HubspotAppToken.credentials.ts index 4c5b35a9af..23758351c6 100644 --- a/packages/nodes-base/credentials/HubspotAppToken.credentials.ts +++ b/packages/nodes-base/credentials/HubspotAppToken.credentials.ts @@ -7,8 +7,11 @@ import { export class HubspotAppToken implements ICredentialType { name = 'hubspotAppToken'; + displayName = 'HubSpot App Token'; + documentationUrl = 'hubspot'; + properties: INodeProperties[] = [ { displayName: 'APP Token', diff --git a/packages/nodes-base/credentials/HubspotDeveloperApi.credentials.ts b/packages/nodes-base/credentials/HubspotDeveloperApi.credentials.ts index 9b2eaed2c6..7669adaad2 100644 --- a/packages/nodes-base/credentials/HubspotDeveloperApi.credentials.ts +++ b/packages/nodes-base/credentials/HubspotDeveloperApi.credentials.ts @@ -13,10 +13,14 @@ const scopes = [ export class HubspotDeveloperApi implements ICredentialType { // eslint-disable-next-line n8n-nodes-base/cred-class-field-name-missing-oauth2 name = 'hubspotDeveloperApi'; + // eslint-disable-next-line n8n-nodes-base/cred-class-field-display-name-missing-oauth2 displayName = 'HubSpot Developer API'; + documentationUrl = 'hubspot'; + extends = ['oAuth2Api']; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/HubspotOAuth2Api.credentials.ts b/packages/nodes-base/credentials/HubspotOAuth2Api.credentials.ts index 2296bf68e9..2b902408bf 100644 --- a/packages/nodes-base/credentials/HubspotOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/HubspotOAuth2Api.credentials.ts @@ -17,9 +17,13 @@ const scopes = [ export class HubspotOAuth2Api implements ICredentialType { name = 'hubspotOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'HubSpot OAuth2 API'; + documentationUrl = 'hubspot'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/HumanticAiApi.credentials.ts b/packages/nodes-base/credentials/HumanticAiApi.credentials.ts index 6b0b0a6b52..cdc705ff5e 100644 --- a/packages/nodes-base/credentials/HumanticAiApi.credentials.ts +++ b/packages/nodes-base/credentials/HumanticAiApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HumanticAiApi implements ICredentialType { name = 'humanticAiApi'; + displayName = 'Humantic AI API'; + documentationUrl = 'humanticAi'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/HunterApi.credentials.ts b/packages/nodes-base/credentials/HunterApi.credentials.ts index baebbc3102..1d0a83640c 100644 --- a/packages/nodes-base/credentials/HunterApi.credentials.ts +++ b/packages/nodes-base/credentials/HunterApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class HunterApi implements ICredentialType { name = 'hunterApi'; + displayName = 'Hunter API'; + documentationUrl = 'hunter'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/Imap.credentials.ts b/packages/nodes-base/credentials/Imap.credentials.ts index 856835dfe4..172bab7ad5 100644 --- a/packages/nodes-base/credentials/Imap.credentials.ts +++ b/packages/nodes-base/credentials/Imap.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Imap implements ICredentialType { name = 'imap'; + displayName = 'IMAP'; + documentationUrl = 'imap'; + properties: INodeProperties[] = [ { displayName: 'User', diff --git a/packages/nodes-base/credentials/IntercomApi.credentials.ts b/packages/nodes-base/credentials/IntercomApi.credentials.ts index eb71441083..ee00a0da2b 100644 --- a/packages/nodes-base/credentials/IntercomApi.credentials.ts +++ b/packages/nodes-base/credentials/IntercomApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class IntercomApi implements ICredentialType { name = 'intercomApi'; + displayName = 'Intercom API'; + documentationUrl = 'intercom'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/InvoiceNinjaApi.credentials.ts b/packages/nodes-base/credentials/InvoiceNinjaApi.credentials.ts index b85e0b6816..7b84509ed9 100644 --- a/packages/nodes-base/credentials/InvoiceNinjaApi.credentials.ts +++ b/packages/nodes-base/credentials/InvoiceNinjaApi.credentials.ts @@ -8,8 +8,11 @@ import { export class InvoiceNinjaApi implements ICredentialType { name = 'invoiceNinjaApi'; + displayName = 'Invoice Ninja API'; + documentationUrl = 'invoiceNinja'; + properties: INodeProperties[] = [ { displayName: 'URL', @@ -32,6 +35,7 @@ export class InvoiceNinjaApi implements ICredentialType { hint: 'This is optional, enter only if you did set a secret in your app and only if you are using v5', }, ]; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials?.url}}', @@ -39,6 +43,7 @@ export class InvoiceNinjaApi implements ICredentialType { method: 'GET', }, }; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, diff --git a/packages/nodes-base/credentials/IterableApi.credentials.ts b/packages/nodes-base/credentials/IterableApi.credentials.ts index 8f90d77d46..cab6ff71ee 100644 --- a/packages/nodes-base/credentials/IterableApi.credentials.ts +++ b/packages/nodes-base/credentials/IterableApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class IterableApi implements ICredentialType { name = 'iterableApi'; + displayName = 'Iterable API'; + documentationUrl = 'iterable'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/JenkinsApi.credentials.ts b/packages/nodes-base/credentials/JenkinsApi.credentials.ts index a1470aead9..721c5ddac8 100644 --- a/packages/nodes-base/credentials/JenkinsApi.credentials.ts +++ b/packages/nodes-base/credentials/JenkinsApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class JenkinsApi implements ICredentialType { name = 'jenkinsApi'; + displayName = 'Jenkins API'; + documentationUrl = 'jenkins'; + properties: INodeProperties[] = [ { displayName: 'Jenking Username', diff --git a/packages/nodes-base/credentials/JiraSoftwareCloudApi.credentials.ts b/packages/nodes-base/credentials/JiraSoftwareCloudApi.credentials.ts index 414dc9bfac..30ea688d07 100644 --- a/packages/nodes-base/credentials/JiraSoftwareCloudApi.credentials.ts +++ b/packages/nodes-base/credentials/JiraSoftwareCloudApi.credentials.ts @@ -7,8 +7,11 @@ import { export class JiraSoftwareCloudApi implements ICredentialType { name = 'jiraSoftwareCloudApi'; + displayName = 'Jira SW Cloud API'; + documentationUrl = 'jira'; + properties: INodeProperties[] = [ { displayName: 'Email', @@ -31,6 +34,7 @@ export class JiraSoftwareCloudApi implements ICredentialType { placeholder: 'https://example.atlassian.net', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -40,6 +44,7 @@ export class JiraSoftwareCloudApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials?.domain}}', diff --git a/packages/nodes-base/credentials/JiraSoftwareServerApi.credentials.ts b/packages/nodes-base/credentials/JiraSoftwareServerApi.credentials.ts index 5e09132165..0a5ff8b918 100644 --- a/packages/nodes-base/credentials/JiraSoftwareServerApi.credentials.ts +++ b/packages/nodes-base/credentials/JiraSoftwareServerApi.credentials.ts @@ -7,8 +7,11 @@ import { export class JiraSoftwareServerApi implements ICredentialType { name = 'jiraSoftwareServerApi'; + displayName = 'Jira SW Server API'; + documentationUrl = 'jira'; + properties: INodeProperties[] = [ { displayName: 'Email', @@ -34,6 +37,7 @@ export class JiraSoftwareServerApi implements ICredentialType { placeholder: 'https://example.com', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -43,6 +47,7 @@ export class JiraSoftwareServerApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials?.domain}}', diff --git a/packages/nodes-base/credentials/JotFormApi.credentials.ts b/packages/nodes-base/credentials/JotFormApi.credentials.ts index a529dfee99..2d90c344b0 100644 --- a/packages/nodes-base/credentials/JotFormApi.credentials.ts +++ b/packages/nodes-base/credentials/JotFormApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class JotFormApi implements ICredentialType { name = 'jotFormApi'; + displayName = 'JotForm API'; + documentationUrl = 'jotForm'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/Kafka.credentials.ts b/packages/nodes-base/credentials/Kafka.credentials.ts index a27f008589..0e96ec69bd 100644 --- a/packages/nodes-base/credentials/Kafka.credentials.ts +++ b/packages/nodes-base/credentials/Kafka.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Kafka implements ICredentialType { name = 'kafka'; + displayName = 'Kafka'; + documentationUrl = 'kafka'; + properties: INodeProperties[] = [ { displayName: 'Client ID', diff --git a/packages/nodes-base/credentials/KeapOAuth2Api.credentials.ts b/packages/nodes-base/credentials/KeapOAuth2Api.credentials.ts index d6cf0856e1..099e8aa29b 100644 --- a/packages/nodes-base/credentials/KeapOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/KeapOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['full']; export class KeapOAuth2Api implements ICredentialType { name = 'keapOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Keap OAuth2 API'; + documentationUrl = 'keap'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/KitemakerApi.credentials.ts b/packages/nodes-base/credentials/KitemakerApi.credentials.ts index baebc90637..3932e62449 100644 --- a/packages/nodes-base/credentials/KitemakerApi.credentials.ts +++ b/packages/nodes-base/credentials/KitemakerApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class KitemakerApi implements ICredentialType { name = 'kitemakerApi'; + displayName = 'Kitemaker API'; + documentationUrl = 'kitemaker'; + properties: INodeProperties[] = [ { displayName: 'Personal Access Token', diff --git a/packages/nodes-base/credentials/KoBoToolboxApi.credentials.ts b/packages/nodes-base/credentials/KoBoToolboxApi.credentials.ts index 38e54c4f91..2f76135925 100644 --- a/packages/nodes-base/credentials/KoBoToolboxApi.credentials.ts +++ b/packages/nodes-base/credentials/KoBoToolboxApi.credentials.ts @@ -7,9 +7,12 @@ import { export class KoBoToolboxApi implements ICredentialType { name = 'koBoToolboxApi'; + displayName = 'KoBoToolbox API Token'; + // See https://support.kobotoolbox.org/api.html documentationUrl = 'koBoToolbox'; + properties = [ { displayName: 'API Root URL', @@ -25,6 +28,7 @@ export class KoBoToolboxApi implements ICredentialType { hint: 'You can get your API token at https://[api-root]/token/?format=json (for a logged in user)', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/LemlistApi.credentials.ts b/packages/nodes-base/credentials/LemlistApi.credentials.ts index c2a0e90138..f8e6529ee1 100644 --- a/packages/nodes-base/credentials/LemlistApi.credentials.ts +++ b/packages/nodes-base/credentials/LemlistApi.credentials.ts @@ -8,8 +8,11 @@ import { export class LemlistApi implements ICredentialType { name = 'lemlistApi'; + displayName = 'Lemlist API'; + documentationUrl = 'lemlist'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -19,15 +22,17 @@ export class LemlistApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, ): Promise { const encodedApiKey = Buffer.from(':' + credentials.apiKey).toString('base64'); - requestOptions.headers!['Authorization'] = `Basic ${encodedApiKey}`; + requestOptions.headers!.Authorization = `Basic ${encodedApiKey}`; requestOptions.headers!['user-agent'] = 'n8n'; return requestOptions; } + test: ICredentialTestRequest = { request: { baseURL: 'https://api.lemlist.com/api', diff --git a/packages/nodes-base/credentials/LineNotifyOAuth2Api.credentials.ts b/packages/nodes-base/credentials/LineNotifyOAuth2Api.credentials.ts index 4edd38e245..a8815596d1 100644 --- a/packages/nodes-base/credentials/LineNotifyOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/LineNotifyOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class LineNotifyOAuth2Api implements ICredentialType { name = 'lineNotifyOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Line Notify OAuth2 API'; + documentationUrl = 'line'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/LinearApi.credentials.ts b/packages/nodes-base/credentials/LinearApi.credentials.ts index f836589386..3b96080274 100644 --- a/packages/nodes-base/credentials/LinearApi.credentials.ts +++ b/packages/nodes-base/credentials/LinearApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class LinearApi implements ICredentialType { name = 'linearApi'; + displayName = 'Linear API'; + documentationUrl = 'linear'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/LingvaNexApi.credentials.ts b/packages/nodes-base/credentials/LingvaNexApi.credentials.ts index b737f22e36..9ce7058497 100644 --- a/packages/nodes-base/credentials/LingvaNexApi.credentials.ts +++ b/packages/nodes-base/credentials/LingvaNexApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class LingvaNexApi implements ICredentialType { name = 'lingvaNexApi'; + displayName = 'LingvaNex API'; + documentationUrl = 'lingvaNex'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/LinkedInOAuth2Api.credentials.ts b/packages/nodes-base/credentials/LinkedInOAuth2Api.credentials.ts index 6f291d2840..0cae7260ca 100644 --- a/packages/nodes-base/credentials/LinkedInOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/LinkedInOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class LinkedInOAuth2Api implements ICredentialType { name = 'linkedInOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'LinkedIn OAuth2 API'; + documentationUrl = 'linkedIn'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/Magento2Api.credentials.ts b/packages/nodes-base/credentials/Magento2Api.credentials.ts index aa98595b8d..a56b437a70 100644 --- a/packages/nodes-base/credentials/Magento2Api.credentials.ts +++ b/packages/nodes-base/credentials/Magento2Api.credentials.ts @@ -7,8 +7,11 @@ import { export class Magento2Api implements ICredentialType { name = 'magento2Api'; + displayName = 'Magento 2 API'; + documentationUrl = 'magento2'; + properties: INodeProperties[] = [ { displayName: 'Host', @@ -24,6 +27,7 @@ export class Magento2Api implements ICredentialType { default: '', }, ]; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials.host}}', diff --git a/packages/nodes-base/credentials/MailcheckApi.credentials.ts b/packages/nodes-base/credentials/MailcheckApi.credentials.ts index fc32abf9ae..bcfec7eaf4 100644 --- a/packages/nodes-base/credentials/MailcheckApi.credentials.ts +++ b/packages/nodes-base/credentials/MailcheckApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MailcheckApi implements ICredentialType { name = 'mailcheckApi'; + displayName = 'Mailcheck API'; + documentationUrl = 'mailcheck'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/MailchimpApi.credentials.ts b/packages/nodes-base/credentials/MailchimpApi.credentials.ts index c21eb3cace..bd75c4b809 100644 --- a/packages/nodes-base/credentials/MailchimpApi.credentials.ts +++ b/packages/nodes-base/credentials/MailchimpApi.credentials.ts @@ -7,8 +7,11 @@ import { export class MailchimpApi implements ICredentialType { name = 'mailchimpApi'; + displayName = 'Mailchimp API'; + documentationUrl = 'mailchimp'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class MailchimpApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class MailchimpApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '=https://{{$credentials.apiKey.split("-").pop()}}.api.mailchimp.com/3.0', diff --git a/packages/nodes-base/credentials/MailchimpOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MailchimpOAuth2Api.credentials.ts index 3b321c3c4f..45f945b8b9 100644 --- a/packages/nodes-base/credentials/MailchimpOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MailchimpOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MailchimpOAuth2Api implements ICredentialType { name = 'mailchimpOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Mailchimp OAuth2 API'; + documentationUrl = 'mailchimp'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/MailerLiteApi.credentials.ts b/packages/nodes-base/credentials/MailerLiteApi.credentials.ts index ca6418b2b7..0c60e97800 100644 --- a/packages/nodes-base/credentials/MailerLiteApi.credentials.ts +++ b/packages/nodes-base/credentials/MailerLiteApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MailerLiteApi implements ICredentialType { name = 'mailerLiteApi'; + displayName = 'Mailer Lite API'; + documentationUrl = 'mailerLite'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/MailgunApi.credentials.ts b/packages/nodes-base/credentials/MailgunApi.credentials.ts index 7c56d1447c..5dd9429396 100644 --- a/packages/nodes-base/credentials/MailgunApi.credentials.ts +++ b/packages/nodes-base/credentials/MailgunApi.credentials.ts @@ -7,8 +7,11 @@ import { export class MailgunApi implements ICredentialType { name = 'mailgunApi'; + displayName = 'Mailgun API'; + documentationUrl = 'mailgun'; + properties: INodeProperties[] = [ { displayName: 'API Domain', @@ -41,6 +44,7 @@ export class MailgunApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -50,6 +54,7 @@ export class MailgunApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '=https://{{$credentials.apiDomain}}/v3', diff --git a/packages/nodes-base/credentials/MailjetEmailApi.credentials.ts b/packages/nodes-base/credentials/MailjetEmailApi.credentials.ts index e04a2601b8..59d492e865 100644 --- a/packages/nodes-base/credentials/MailjetEmailApi.credentials.ts +++ b/packages/nodes-base/credentials/MailjetEmailApi.credentials.ts @@ -7,8 +7,11 @@ import { export class MailjetEmailApi implements ICredentialType { name = 'mailjetEmailApi'; + displayName = 'Mailjet Email API'; + documentationUrl = 'mailjet'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/MailjetSmsApi.credentials.ts b/packages/nodes-base/credentials/MailjetSmsApi.credentials.ts index 196069371a..26a5eaff26 100644 --- a/packages/nodes-base/credentials/MailjetSmsApi.credentials.ts +++ b/packages/nodes-base/credentials/MailjetSmsApi.credentials.ts @@ -7,8 +7,11 @@ import { export class MailjetSmsApi implements ICredentialType { name = 'mailjetSmsApi'; + displayName = 'Mailjet SMS API'; + documentationUrl = 'mailjet'; + properties: INodeProperties[] = [ { displayName: 'Token', diff --git a/packages/nodes-base/credentials/MandrillApi.credentials.ts b/packages/nodes-base/credentials/MandrillApi.credentials.ts index 786d7bafff..7880a3ccca 100644 --- a/packages/nodes-base/credentials/MandrillApi.credentials.ts +++ b/packages/nodes-base/credentials/MandrillApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MandrillApi implements ICredentialType { name = 'mandrillApi'; + displayName = 'Mandrill API'; + documentationUrl = 'mandrill'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/MarketstackApi.credentials.ts b/packages/nodes-base/credentials/MarketstackApi.credentials.ts index 80bbafdb68..5ca3bec5a4 100644 --- a/packages/nodes-base/credentials/MarketstackApi.credentials.ts +++ b/packages/nodes-base/credentials/MarketstackApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MarketstackApi implements ICredentialType { name = 'marketstackApi'; + displayName = 'Marketstack API'; + documentationUrl = 'marketstack'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/MatrixApi.credentials.ts b/packages/nodes-base/credentials/MatrixApi.credentials.ts index ca1158b5fd..84322d86fb 100644 --- a/packages/nodes-base/credentials/MatrixApi.credentials.ts +++ b/packages/nodes-base/credentials/MatrixApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MatrixApi implements ICredentialType { name = 'matrixApi'; + displayName = 'Matrix API'; + documentationUrl = 'matrix'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/MattermostApi.credentials.ts b/packages/nodes-base/credentials/MattermostApi.credentials.ts index a422c3a727..d819a223f7 100644 --- a/packages/nodes-base/credentials/MattermostApi.credentials.ts +++ b/packages/nodes-base/credentials/MattermostApi.credentials.ts @@ -7,8 +7,11 @@ import { export class MattermostApi implements ICredentialType { name = 'mattermostApi'; + displayName = 'Mattermost API'; + documentationUrl = 'mattermost'; + properties: INodeProperties[] = [ { displayName: 'Access Token', @@ -24,6 +27,7 @@ export class MattermostApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -32,6 +36,7 @@ export class MattermostApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials.baseUrl}}/api/v4', diff --git a/packages/nodes-base/credentials/MauticApi.credentials.ts b/packages/nodes-base/credentials/MauticApi.credentials.ts index 59554826b0..c852b4415e 100644 --- a/packages/nodes-base/credentials/MauticApi.credentials.ts +++ b/packages/nodes-base/credentials/MauticApi.credentials.ts @@ -7,8 +7,11 @@ import { export class MauticApi implements ICredentialType { name = 'mauticApi'; + displayName = 'Mautic API'; + documentationUrl = 'mautic'; + properties: INodeProperties[] = [ { displayName: 'URL', diff --git a/packages/nodes-base/credentials/MauticOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MauticOAuth2Api.credentials.ts index afa26e84a7..47fe1b3939 100644 --- a/packages/nodes-base/credentials/MauticOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MauticOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MauticOAuth2Api implements ICredentialType { name = 'mauticOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Mautic OAuth2 API'; + documentationUrl = 'mautic'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/MediumApi.credentials.ts b/packages/nodes-base/credentials/MediumApi.credentials.ts index 98537b3e5f..0f82fc592a 100644 --- a/packages/nodes-base/credentials/MediumApi.credentials.ts +++ b/packages/nodes-base/credentials/MediumApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MediumApi implements ICredentialType { name = 'mediumApi'; + displayName = 'Medium API'; + documentationUrl = 'medium'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/MediumOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MediumOAuth2Api.credentials.ts index fdbc200834..0d872d41c7 100644 --- a/packages/nodes-base/credentials/MediumOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MediumOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MediumOAuth2Api implements ICredentialType { name = 'mediumOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Medium OAuth2 API'; + documentationUrl = 'medium'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/MessageBirdApi.credentials.ts b/packages/nodes-base/credentials/MessageBirdApi.credentials.ts index 3850328dc7..461e1c9568 100644 --- a/packages/nodes-base/credentials/MessageBirdApi.credentials.ts +++ b/packages/nodes-base/credentials/MessageBirdApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MessageBirdApi implements ICredentialType { name = 'messageBirdApi'; + displayName = 'MessageBird API'; + documentationUrl = 'messageBird'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/MetabaseApi.credentials.ts b/packages/nodes-base/credentials/MetabaseApi.credentials.ts index 6de56d4764..f0e7c8874e 100644 --- a/packages/nodes-base/credentials/MetabaseApi.credentials.ts +++ b/packages/nodes-base/credentials/MetabaseApi.credentials.ts @@ -9,8 +9,11 @@ import { export class MetabaseApi implements ICredentialType { name = 'metabaseApi'; + displayName = 'Metabase API'; + documentationUrl = 'metabase'; + properties: INodeProperties[] = [ { displayName: 'Session Token', @@ -59,6 +62,7 @@ export class MetabaseApi implements ICredentialType { })) as { id: string }; return { sessionToken: id }; } + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -67,6 +71,7 @@ export class MetabaseApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials?.url}}', diff --git a/packages/nodes-base/credentials/MicrosoftDynamicsOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MicrosoftDynamicsOAuth2Api.credentials.ts index 63446a3ed6..2111f8f881 100644 --- a/packages/nodes-base/credentials/MicrosoftDynamicsOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftDynamicsOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftDynamicsOAuth2Api implements ICredentialType { name = 'microsoftDynamicsOAuth2Api'; + extends = ['microsoftOAuth2Api']; + displayName = 'Microsoft Dynamics OAuth2 API'; + documentationUrl = 'microsoft'; + properties: INodeProperties[] = [ // https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent { diff --git a/packages/nodes-base/credentials/MicrosoftExcelOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MicrosoftExcelOAuth2Api.credentials.ts index 8a43e30b15..dfb7d4f2fc 100644 --- a/packages/nodes-base/credentials/MicrosoftExcelOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftExcelOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftExcelOAuth2Api implements ICredentialType { name = 'microsoftExcelOAuth2Api'; + extends = ['microsoftOAuth2Api']; + displayName = 'Microsoft Excel OAuth2 API'; + documentationUrl = 'microsoft'; + properties: INodeProperties[] = [ //https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent { diff --git a/packages/nodes-base/credentials/MicrosoftGraphSecurityOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MicrosoftGraphSecurityOAuth2Api.credentials.ts index a5022b6c06..5135dc2279 100644 --- a/packages/nodes-base/credentials/MicrosoftGraphSecurityOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftGraphSecurityOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftGraphSecurityOAuth2Api implements ICredentialType { name = 'microsoftGraphSecurityOAuth2Api'; + displayName = 'Microsoft Graph Security OAuth2 API'; + extends = ['microsoftOAuth2Api']; + documentationUrl = 'microsoft'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/MicrosoftOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MicrosoftOAuth2Api.credentials.ts index d02eab5a11..a5e4b61513 100644 --- a/packages/nodes-base/credentials/MicrosoftOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftOAuth2Api.credentials.ts @@ -2,10 +2,15 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftOAuth2Api implements ICredentialType { name = 'microsoftOAuth2Api'; + extends = ['oAuth2Api']; + icon = 'file:Microsoft.svg'; + displayName = 'Microsoft OAuth2 API'; + documentationUrl = 'microsoft'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/MicrosoftOneDriveOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MicrosoftOneDriveOAuth2Api.credentials.ts index 94ec35eb1e..4fceeedcf6 100644 --- a/packages/nodes-base/credentials/MicrosoftOneDriveOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftOneDriveOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftOneDriveOAuth2Api implements ICredentialType { name = 'microsoftOneDriveOAuth2Api'; + extends = ['microsoftOAuth2Api']; + displayName = 'Microsoft Drive OAuth2 API'; + documentationUrl = 'microsoft'; + properties: INodeProperties[] = [ //https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent { diff --git a/packages/nodes-base/credentials/MicrosoftOutlookOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MicrosoftOutlookOAuth2Api.credentials.ts index 9627b3294c..312a2ea3ba 100644 --- a/packages/nodes-base/credentials/MicrosoftOutlookOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftOutlookOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftOutlookOAuth2Api implements ICredentialType { name = 'microsoftOutlookOAuth2Api'; + extends = ['microsoftOAuth2Api']; + displayName = 'Microsoft Outlook OAuth2 API'; + documentationUrl = 'microsoft'; + properties: INodeProperties[] = [ //https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent { diff --git a/packages/nodes-base/credentials/MicrosoftSql.credentials.ts b/packages/nodes-base/credentials/MicrosoftSql.credentials.ts index bf6f2183c1..e0bba547e7 100644 --- a/packages/nodes-base/credentials/MicrosoftSql.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftSql.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftSql implements ICredentialType { name = 'microsoftSql'; + displayName = 'Microsoft SQL'; + documentationUrl = 'microsoftSql'; + properties: INodeProperties[] = [ { displayName: 'Server', diff --git a/packages/nodes-base/credentials/MicrosoftTeamsOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MicrosoftTeamsOAuth2Api.credentials.ts index 97dc7cfb59..549aac66a6 100644 --- a/packages/nodes-base/credentials/MicrosoftTeamsOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftTeamsOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftTeamsOAuth2Api implements ICredentialType { name = 'microsoftTeamsOAuth2Api'; + extends = ['microsoftOAuth2Api']; + displayName = 'Microsoft Teams OAuth2 API'; + documentationUrl = 'microsoft'; + properties: INodeProperties[] = [ //https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent { diff --git a/packages/nodes-base/credentials/MicrosoftToDoOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MicrosoftToDoOAuth2Api.credentials.ts index aa8c12da80..c457c4e8dd 100644 --- a/packages/nodes-base/credentials/MicrosoftToDoOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MicrosoftToDoOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MicrosoftToDoOAuth2Api implements ICredentialType { name = 'microsoftToDoOAuth2Api'; + extends = ['microsoftOAuth2Api']; + displayName = 'Microsoft To Do OAuth2 API'; + documentationUrl = 'microsoft'; + properties: INodeProperties[] = [ //https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent { diff --git a/packages/nodes-base/credentials/MindeeInvoiceApi.credentials.ts b/packages/nodes-base/credentials/MindeeInvoiceApi.credentials.ts index c28ef1d32a..e90e353013 100644 --- a/packages/nodes-base/credentials/MindeeInvoiceApi.credentials.ts +++ b/packages/nodes-base/credentials/MindeeInvoiceApi.credentials.ts @@ -7,8 +7,11 @@ import { export class MindeeInvoiceApi implements ICredentialType { name = 'mindeeInvoiceApi'; + displayName = 'Mindee Invoice API'; + documentationUrl = 'mindee'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class MindeeInvoiceApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -25,7 +29,7 @@ export class MindeeInvoiceApi implements ICredentialType { // @ts-ignore const url = requestOptions.url ? requestOptions.url : requestOptions.uri; if (url.includes('https://api.mindee.net/v1/')) { - requestOptions.headers!['Authorization'] = `Token ${credentials.apiKey}`; + requestOptions.headers!.Authorization = `Token ${credentials.apiKey}`; } else { requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`; } diff --git a/packages/nodes-base/credentials/MindeeReceiptApi.credentials.ts b/packages/nodes-base/credentials/MindeeReceiptApi.credentials.ts index 9b5a013d3e..a12dcc8bbf 100644 --- a/packages/nodes-base/credentials/MindeeReceiptApi.credentials.ts +++ b/packages/nodes-base/credentials/MindeeReceiptApi.credentials.ts @@ -7,8 +7,11 @@ import { export class MindeeReceiptApi implements ICredentialType { name = 'mindeeReceiptApi'; + displayName = 'Mindee Receipt API'; + documentationUrl = 'mindee'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class MindeeReceiptApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -25,7 +29,7 @@ export class MindeeReceiptApi implements ICredentialType { // @ts-ignore const url = requestOptions.url ? requestOptions.url : requestOptions.uri; if (url.includes('https://api.mindee.net/v1/')) { - requestOptions.headers!['Authorization'] = `Token ${credentials.apiKey}`; + requestOptions.headers!.Authorization = `Token ${credentials.apiKey}`; } else { requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`; } diff --git a/packages/nodes-base/credentials/MispApi.credentials.ts b/packages/nodes-base/credentials/MispApi.credentials.ts index a0c6d975b0..77e730af3d 100644 --- a/packages/nodes-base/credentials/MispApi.credentials.ts +++ b/packages/nodes-base/credentials/MispApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MispApi implements ICredentialType { name = 'mispApi'; + displayName = 'MISP API'; + documentationUrl = 'misp'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/MoceanApi.credentials.ts b/packages/nodes-base/credentials/MoceanApi.credentials.ts index 5d432341ee..1090e9da95 100644 --- a/packages/nodes-base/credentials/MoceanApi.credentials.ts +++ b/packages/nodes-base/credentials/MoceanApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MoceanApi implements ICredentialType { name = 'moceanApi'; + displayName = 'Mocean Api'; + documentationUrl = 'mocean'; + properties: INodeProperties[] = [ // The credentials to get from user and save encrypted. // Properties can be defined exactly in the same way diff --git a/packages/nodes-base/credentials/MondayComApi.credentials.ts b/packages/nodes-base/credentials/MondayComApi.credentials.ts index c35464da18..e3e3266a13 100644 --- a/packages/nodes-base/credentials/MondayComApi.credentials.ts +++ b/packages/nodes-base/credentials/MondayComApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MondayComApi implements ICredentialType { name = 'mondayComApi'; + displayName = 'Monday.com API'; + documentationUrl = 'mondayCom'; + properties: INodeProperties[] = [ { displayName: 'Token V2', diff --git a/packages/nodes-base/credentials/MondayComOAuth2Api.credentials.ts b/packages/nodes-base/credentials/MondayComOAuth2Api.credentials.ts index 4fd46c63fd..ac1ea8a58c 100644 --- a/packages/nodes-base/credentials/MondayComOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/MondayComOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['boards:write', 'boards:read']; export class MondayComOAuth2Api implements ICredentialType { name = 'mondayComOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Monday.com OAuth2 API'; + documentationUrl = 'monday'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/MongoDb.credentials.ts b/packages/nodes-base/credentials/MongoDb.credentials.ts index 22c0a69da5..c43be57b93 100644 --- a/packages/nodes-base/credentials/MongoDb.credentials.ts +++ b/packages/nodes-base/credentials/MongoDb.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MongoDb implements ICredentialType { name = 'mongoDb'; + displayName = 'MongoDB'; + documentationUrl = 'mongoDb'; + properties: INodeProperties[] = [ { displayName: 'Configuration Type', diff --git a/packages/nodes-base/credentials/MonicaCrmApi.credentials.ts b/packages/nodes-base/credentials/MonicaCrmApi.credentials.ts index b1e44c9123..40b54bcc13 100644 --- a/packages/nodes-base/credentials/MonicaCrmApi.credentials.ts +++ b/packages/nodes-base/credentials/MonicaCrmApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MonicaCrmApi implements ICredentialType { name = 'monicaCrmApi'; + displayName = 'Monica CRM API'; + documentationUrl = 'monicaCrm'; + properties: INodeProperties[] = [ { displayName: 'Environment', diff --git a/packages/nodes-base/credentials/Mqtt.credentials.ts b/packages/nodes-base/credentials/Mqtt.credentials.ts index 4d2961959b..ac9808af0a 100644 --- a/packages/nodes-base/credentials/Mqtt.credentials.ts +++ b/packages/nodes-base/credentials/Mqtt.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, IDisplayOptions, INodeProperties } from 'n8n-workflow' export class Mqtt implements ICredentialType { name = 'mqtt'; + displayName = 'MQTT'; + documentationUrl = 'mqtt'; + properties: INodeProperties[] = [ { displayName: 'Protocol', diff --git a/packages/nodes-base/credentials/Msg91Api.credentials.ts b/packages/nodes-base/credentials/Msg91Api.credentials.ts index 08c6636179..7571453a49 100644 --- a/packages/nodes-base/credentials/Msg91Api.credentials.ts +++ b/packages/nodes-base/credentials/Msg91Api.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Msg91Api implements ICredentialType { name = 'msg91Api'; + displayName = 'Msg91 Api'; + documentationUrl = 'msg91'; + properties: INodeProperties[] = [ // User authentication key { diff --git a/packages/nodes-base/credentials/MySql.credentials.ts b/packages/nodes-base/credentials/MySql.credentials.ts index 81ba4beaaf..af1e937d63 100644 --- a/packages/nodes-base/credentials/MySql.credentials.ts +++ b/packages/nodes-base/credentials/MySql.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class MySql implements ICredentialType { name = 'mySql'; + displayName = 'MySQL'; + documentationUrl = 'mySql'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/N8nApi.credentials.ts b/packages/nodes-base/credentials/N8nApi.credentials.ts index 60ea16130b..f452867d55 100644 --- a/packages/nodes-base/credentials/N8nApi.credentials.ts +++ b/packages/nodes-base/credentials/N8nApi.credentials.ts @@ -7,8 +7,11 @@ import { export class N8nApi implements ICredentialType { name = 'n8nApi'; + displayName = 'n8n API'; + documentationUrl = 'n8nApi'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -27,6 +30,7 @@ export class N8nApi implements ICredentialType { description: 'The API URL of the n8n instance', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -35,6 +39,7 @@ export class N8nApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{ $credentials.baseUrl }}', diff --git a/packages/nodes-base/credentials/NasaApi.credentials.ts b/packages/nodes-base/credentials/NasaApi.credentials.ts index e8d327df2a..c3f464c9ec 100644 --- a/packages/nodes-base/credentials/NasaApi.credentials.ts +++ b/packages/nodes-base/credentials/NasaApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class NasaApi implements ICredentialType { name = 'nasaApi'; + displayName = 'NASA API'; + documentationUrl = 'nasa'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/NetlifyApi.credentials.ts b/packages/nodes-base/credentials/NetlifyApi.credentials.ts index 0d7a3cfcc2..fda8ed0228 100644 --- a/packages/nodes-base/credentials/NetlifyApi.credentials.ts +++ b/packages/nodes-base/credentials/NetlifyApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, NodePropertyTypes } from 'n8n-workflow'; export class NetlifyApi implements ICredentialType { name = 'netlifyApi'; + displayName = 'Netlify API'; + documentationUrl = 'netlify'; + properties = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/NextCloudApi.credentials.ts b/packages/nodes-base/credentials/NextCloudApi.credentials.ts index 9357898c83..1e6a29b5c9 100644 --- a/packages/nodes-base/credentials/NextCloudApi.credentials.ts +++ b/packages/nodes-base/credentials/NextCloudApi.credentials.ts @@ -8,8 +8,11 @@ import { export class NextCloudApi implements ICredentialType { name = 'nextCloudApi'; + displayName = 'NextCloud API'; + documentationUrl = 'nextCloud'; + properties: INodeProperties[] = [ { displayName: 'Web DAV URL', @@ -32,6 +35,7 @@ export class NextCloudApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -42,6 +46,7 @@ export class NextCloudApi implements ICredentialType { }; return requestOptions; } + test: ICredentialTestRequest = { request: { baseURL: "={{$credentials.webDavUrl.replace('/remote.php/webdav', '')}}", diff --git a/packages/nodes-base/credentials/NextCloudOAuth2Api.credentials.ts b/packages/nodes-base/credentials/NextCloudOAuth2Api.credentials.ts index f9868d89b0..90f62b07bf 100644 --- a/packages/nodes-base/credentials/NextCloudOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/NextCloudOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class NextCloudOAuth2Api implements ICredentialType { name = 'nextCloudOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'NextCloud OAuth2 API'; + documentationUrl = 'nextCloud'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/NocoDb.credentials.ts b/packages/nodes-base/credentials/NocoDb.credentials.ts index 852d3f3be1..193e0e5ebf 100644 --- a/packages/nodes-base/credentials/NocoDb.credentials.ts +++ b/packages/nodes-base/credentials/NocoDb.credentials.ts @@ -2,8 +2,11 @@ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-work export class NocoDb implements ICredentialType { name = 'nocoDb'; + displayName = 'NocoDB'; + documentationUrl = 'nocoDb'; + properties: INodeProperties[] = [ { displayName: 'User Token', @@ -19,6 +22,7 @@ export class NocoDb implements ICredentialType { placeholder: 'http(s)://localhost:8080', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/NocoDbApiToken.credentials.ts b/packages/nodes-base/credentials/NocoDbApiToken.credentials.ts index aed28e58ca..c5ac2530e5 100644 --- a/packages/nodes-base/credentials/NocoDbApiToken.credentials.ts +++ b/packages/nodes-base/credentials/NocoDbApiToken.credentials.ts @@ -2,8 +2,11 @@ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-work export class NocoDbApiToken implements ICredentialType { name = 'nocoDbApiToken'; + displayName = 'NocoDB API Token'; + documentationUrl = 'nocoDb'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/NotionApi.credentials.ts b/packages/nodes-base/credentials/NotionApi.credentials.ts index 92b93e04ab..99c4d8a5a9 100644 --- a/packages/nodes-base/credentials/NotionApi.credentials.ts +++ b/packages/nodes-base/credentials/NotionApi.credentials.ts @@ -8,8 +8,11 @@ import { export class NotionApi implements ICredentialType { name = 'notionApi'; + displayName = 'Notion API'; + documentationUrl = 'notion'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -19,12 +22,14 @@ export class NotionApi implements ICredentialType { default: '', }, ]; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.notion.com/v1', url: '/users', }, }; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, diff --git a/packages/nodes-base/credentials/NotionOAuth2Api.credentials.ts b/packages/nodes-base/credentials/NotionOAuth2Api.credentials.ts index 7f1e61af1e..dc35b9782a 100644 --- a/packages/nodes-base/credentials/NotionOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/NotionOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class NotionOAuth2Api implements ICredentialType { name = 'notionOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Notion OAuth2 API'; + documentationUrl = 'notion'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/OAuth1Api.credentials.ts b/packages/nodes-base/credentials/OAuth1Api.credentials.ts index 132ea60e96..d28a601921 100644 --- a/packages/nodes-base/credentials/OAuth1Api.credentials.ts +++ b/packages/nodes-base/credentials/OAuth1Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class OAuth1Api implements ICredentialType { name = 'oAuth1Api'; + displayName = 'OAuth1 API'; + documentationUrl = 'httpRequest'; + genericAuth = true; + properties: INodeProperties[] = [ { displayName: 'Authorization URL', diff --git a/packages/nodes-base/credentials/OAuth2Api.credentials.ts b/packages/nodes-base/credentials/OAuth2Api.credentials.ts index 3990812008..ce9ed61e43 100644 --- a/packages/nodes-base/credentials/OAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/OAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class OAuth2Api implements ICredentialType { name = 'oAuth2Api'; + displayName = 'OAuth2 API'; + documentationUrl = 'httpRequest'; + genericAuth = true; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/OdooApi.credentials.ts b/packages/nodes-base/credentials/OdooApi.credentials.ts index 91b5e77f76..a28dcc9b62 100644 --- a/packages/nodes-base/credentials/OdooApi.credentials.ts +++ b/packages/nodes-base/credentials/OdooApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties, NodePropertyTypes } from 'n8n-workflo export class OdooApi implements ICredentialType { name = 'odooApi'; + displayName = 'Odoo API'; + documentationUrl = 'odoo'; + properties: INodeProperties[] = [ { displayName: 'Site URL', diff --git a/packages/nodes-base/credentials/OneSimpleApi.credentials.ts b/packages/nodes-base/credentials/OneSimpleApi.credentials.ts index 45a1259690..ca81760379 100644 --- a/packages/nodes-base/credentials/OneSimpleApi.credentials.ts +++ b/packages/nodes-base/credentials/OneSimpleApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class OneSimpleApi implements ICredentialType { name = 'oneSimpleApi'; + displayName = 'One Simple API'; + documentationUrl = 'oneSimpleApi'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/OnfleetApi.credentials.ts b/packages/nodes-base/credentials/OnfleetApi.credentials.ts index f9f34d0ba3..80461af18b 100644 --- a/packages/nodes-base/credentials/OnfleetApi.credentials.ts +++ b/packages/nodes-base/credentials/OnfleetApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, NodePropertyTypes } from 'n8n-workflow'; export class OnfleetApi implements ICredentialType { name = 'onfleetApi'; + displayName = 'Onfleet API'; + documentationUrl = 'onfleet'; + properties = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/OpenWeatherMapApi.credentials.ts b/packages/nodes-base/credentials/OpenWeatherMapApi.credentials.ts index e628ea1346..a8051fbbf3 100644 --- a/packages/nodes-base/credentials/OpenWeatherMapApi.credentials.ts +++ b/packages/nodes-base/credentials/OpenWeatherMapApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class OpenWeatherMapApi implements ICredentialType { name = 'openWeatherMapApi'; + displayName = 'OpenWeatherMap API'; + documentationUrl = 'openWeatherMap'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/OrbitApi.credentials.ts b/packages/nodes-base/credentials/OrbitApi.credentials.ts index 8cef9a23b2..f1946888ac 100644 --- a/packages/nodes-base/credentials/OrbitApi.credentials.ts +++ b/packages/nodes-base/credentials/OrbitApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class OrbitApi implements ICredentialType { name = 'orbitApi'; + displayName = 'Orbit API'; + documentationUrl = 'orbit'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/OuraApi.credentials.ts b/packages/nodes-base/credentials/OuraApi.credentials.ts index 4b48011f65..bc7a2c4d2c 100644 --- a/packages/nodes-base/credentials/OuraApi.credentials.ts +++ b/packages/nodes-base/credentials/OuraApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class OuraApi implements ICredentialType { name = 'ouraApi'; + displayName = 'Oura API'; + documentationUrl = 'oura'; + properties: INodeProperties[] = [ { displayName: 'Personal Access Token', diff --git a/packages/nodes-base/credentials/PaddleApi.credentials.ts b/packages/nodes-base/credentials/PaddleApi.credentials.ts index e82edbf9e2..961c7b2755 100644 --- a/packages/nodes-base/credentials/PaddleApi.credentials.ts +++ b/packages/nodes-base/credentials/PaddleApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PaddleApi implements ICredentialType { name = 'paddleApi'; + displayName = 'Paddle API'; + documentationUrl = 'paddle'; + properties: INodeProperties[] = [ { displayName: 'Vendor Auth Code', diff --git a/packages/nodes-base/credentials/PagerDutyApi.credentials.ts b/packages/nodes-base/credentials/PagerDutyApi.credentials.ts index 9670ba8389..2be92051c3 100644 --- a/packages/nodes-base/credentials/PagerDutyApi.credentials.ts +++ b/packages/nodes-base/credentials/PagerDutyApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PagerDutyApi implements ICredentialType { name = 'pagerDutyApi'; + displayName = 'PagerDuty API'; + documentationUrl = 'pagerDuty'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/PagerDutyOAuth2Api.credentials.ts b/packages/nodes-base/credentials/PagerDutyOAuth2Api.credentials.ts index 7b18cdd60f..55f3acfbb9 100644 --- a/packages/nodes-base/credentials/PagerDutyOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/PagerDutyOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PagerDutyOAuth2Api implements ICredentialType { name = 'pagerDutyOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'PagerDuty OAuth2 API'; + documentationUrl = 'pagerDuty'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/PayPalApi.credentials.ts b/packages/nodes-base/credentials/PayPalApi.credentials.ts index f640598ec2..d8b9a5fd36 100644 --- a/packages/nodes-base/credentials/PayPalApi.credentials.ts +++ b/packages/nodes-base/credentials/PayPalApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PayPalApi implements ICredentialType { name = 'payPalApi'; + displayName = 'PayPal API'; + documentationUrl = 'payPal'; + properties: INodeProperties[] = [ { displayName: 'Client ID', diff --git a/packages/nodes-base/credentials/PeekalinkApi.credentials.ts b/packages/nodes-base/credentials/PeekalinkApi.credentials.ts index 7dcf06013a..5c1c340b0f 100644 --- a/packages/nodes-base/credentials/PeekalinkApi.credentials.ts +++ b/packages/nodes-base/credentials/PeekalinkApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PeekalinkApi implements ICredentialType { name = 'peekalinkApi'; + displayName = 'Peekalink API'; + documentationUrl = 'peekalink'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/PhantombusterApi.credentials.ts b/packages/nodes-base/credentials/PhantombusterApi.credentials.ts index 5e3b7c1cb9..ce3eb8d9ca 100644 --- a/packages/nodes-base/credentials/PhantombusterApi.credentials.ts +++ b/packages/nodes-base/credentials/PhantombusterApi.credentials.ts @@ -7,8 +7,11 @@ import { export class PhantombusterApi implements ICredentialType { name = 'phantombusterApi'; + displayName = 'Phantombuster API'; + documentationUrl = 'phantombuster'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class PhantombusterApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class PhantombusterApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.phantombuster.com/api/v2', diff --git a/packages/nodes-base/credentials/PhilipsHueOAuth2Api.credentials.ts b/packages/nodes-base/credentials/PhilipsHueOAuth2Api.credentials.ts index 99186290cf..8c7b203c4d 100644 --- a/packages/nodes-base/credentials/PhilipsHueOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/PhilipsHueOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PhilipsHueOAuth2Api implements ICredentialType { name = 'philipsHueOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'PhilipHue OAuth2 API'; + documentationUrl = 'philipsHue'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/PipedriveApi.credentials.ts b/packages/nodes-base/credentials/PipedriveApi.credentials.ts index 1f23b52072..2f69fb7335 100644 --- a/packages/nodes-base/credentials/PipedriveApi.credentials.ts +++ b/packages/nodes-base/credentials/PipedriveApi.credentials.ts @@ -2,8 +2,11 @@ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-work export class PipedriveApi implements ICredentialType { name = 'pipedriveApi'; + displayName = 'Pipedrive API'; + documentationUrl = 'pipedrive'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/PipedriveOAuth2Api.credentials.ts b/packages/nodes-base/credentials/PipedriveOAuth2Api.credentials.ts index bbea6ef250..b358e7ee49 100644 --- a/packages/nodes-base/credentials/PipedriveOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/PipedriveOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PipedriveOAuth2Api implements ICredentialType { name = 'pipedriveOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Pipedrive OAuth2 API'; + documentationUrl = 'pipedrive'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/PlivoApi.credentials.ts b/packages/nodes-base/credentials/PlivoApi.credentials.ts index 8f1a8116d2..ec5298a93e 100644 --- a/packages/nodes-base/credentials/PlivoApi.credentials.ts +++ b/packages/nodes-base/credentials/PlivoApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PlivoApi implements ICredentialType { name = 'plivoApi'; + displayName = 'Plivo API'; + documentationUrl = 'plivo'; + properties: INodeProperties[] = [ { displayName: 'Auth ID', diff --git a/packages/nodes-base/credentials/PostHogApi.credentials.ts b/packages/nodes-base/credentials/PostHogApi.credentials.ts index 4c4e4a20a3..ad4e28b6f6 100644 --- a/packages/nodes-base/credentials/PostHogApi.credentials.ts +++ b/packages/nodes-base/credentials/PostHogApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PostHogApi implements ICredentialType { name = 'postHogApi'; + displayName = 'PostHog API'; + documentationUrl = 'postHog'; + properties: INodeProperties[] = [ { displayName: 'URL', diff --git a/packages/nodes-base/credentials/Postgres.credentials.ts b/packages/nodes-base/credentials/Postgres.credentials.ts index 42fbce8ac4..5b78a994c4 100644 --- a/packages/nodes-base/credentials/Postgres.credentials.ts +++ b/packages/nodes-base/credentials/Postgres.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Postgres implements ICredentialType { name = 'postgres'; + displayName = 'Postgres'; + documentationUrl = 'postgres'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/PostmarkApi.credentials.ts b/packages/nodes-base/credentials/PostmarkApi.credentials.ts index aaf969fa67..a6eae4d553 100644 --- a/packages/nodes-base/credentials/PostmarkApi.credentials.ts +++ b/packages/nodes-base/credentials/PostmarkApi.credentials.ts @@ -7,8 +7,11 @@ import { export class PostmarkApi implements ICredentialType { name = 'postmarkApi'; + displayName = 'Postmark API'; + documentationUrl = 'postmark'; + properties: INodeProperties[] = [ { displayName: 'Server API Token', @@ -17,6 +20,7 @@ export class PostmarkApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -25,6 +29,7 @@ export class PostmarkApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.postmarkapp.com', diff --git a/packages/nodes-base/credentials/ProfitWellApi.credentials.ts b/packages/nodes-base/credentials/ProfitWellApi.credentials.ts index 5457b60ad4..d6235fb246 100644 --- a/packages/nodes-base/credentials/ProfitWellApi.credentials.ts +++ b/packages/nodes-base/credentials/ProfitWellApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ProfitWellApi implements ICredentialType { name = 'profitWellApi'; + displayName = 'ProfitWell API'; + documentationUrl = 'profitWell'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/PushbulletOAuth2Api.credentials.ts b/packages/nodes-base/credentials/PushbulletOAuth2Api.credentials.ts index 3e8fa4b119..fa1b52a33f 100644 --- a/packages/nodes-base/credentials/PushbulletOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/PushbulletOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PushbulletOAuth2Api implements ICredentialType { name = 'pushbulletOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Pushbullet OAuth2 API'; + documentationUrl = 'pushbullet'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/PushcutApi.credentials.ts b/packages/nodes-base/credentials/PushcutApi.credentials.ts index adf373c2e3..19ec591e19 100644 --- a/packages/nodes-base/credentials/PushcutApi.credentials.ts +++ b/packages/nodes-base/credentials/PushcutApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class PushcutApi implements ICredentialType { name = 'pushcutApi'; + displayName = 'Pushcut API'; + documentationUrl = 'pushcut'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/PushoverApi.credentials.ts b/packages/nodes-base/credentials/PushoverApi.credentials.ts index 854f3bcd93..07f8600328 100644 --- a/packages/nodes-base/credentials/PushoverApi.credentials.ts +++ b/packages/nodes-base/credentials/PushoverApi.credentials.ts @@ -8,8 +8,11 @@ import { export class PushoverApi implements ICredentialType { name = 'pushoverApi'; + displayName = 'Pushover API'; + documentationUrl = 'pushover'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -19,6 +22,7 @@ export class PushoverApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -30,6 +34,7 @@ export class PushoverApi implements ICredentialType { } return requestOptions; } + test: ICredentialTestRequest = { request: { baseURL: 'https://api.pushover.net/1', diff --git a/packages/nodes-base/credentials/QuestDb.credentials.ts b/packages/nodes-base/credentials/QuestDb.credentials.ts index fe629aff43..6dc5faa0d4 100644 --- a/packages/nodes-base/credentials/QuestDb.credentials.ts +++ b/packages/nodes-base/credentials/QuestDb.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class QuestDb implements ICredentialType { name = 'questDb'; + displayName = 'QuestDB'; + documentationUrl = 'questDb'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/QuickBaseApi.credentials.ts b/packages/nodes-base/credentials/QuickBaseApi.credentials.ts index 25b76031b2..e2dd23370e 100644 --- a/packages/nodes-base/credentials/QuickBaseApi.credentials.ts +++ b/packages/nodes-base/credentials/QuickBaseApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class QuickBaseApi implements ICredentialType { name = 'quickbaseApi'; + displayName = 'Quick Base API'; + documentationUrl = 'quickbase'; + properties: INodeProperties[] = [ { displayName: 'Hostname', diff --git a/packages/nodes-base/credentials/QuickBooksOAuth2Api.credentials.ts b/packages/nodes-base/credentials/QuickBooksOAuth2Api.credentials.ts index f5b0fed2c7..6c1d1d70dc 100644 --- a/packages/nodes-base/credentials/QuickBooksOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/QuickBooksOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class QuickBooksOAuth2Api implements ICredentialType { name = 'quickBooksOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'QuickBooks Online OAuth2 API'; + documentationUrl = 'quickbooks'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/RabbitMQ.credentials.ts b/packages/nodes-base/credentials/RabbitMQ.credentials.ts index 3e3b3cc2ac..297d0a3d98 100644 --- a/packages/nodes-base/credentials/RabbitMQ.credentials.ts +++ b/packages/nodes-base/credentials/RabbitMQ.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, IDisplayOptions, INodeProperties } from 'n8n-workflow' export class RabbitMQ implements ICredentialType { name = 'rabbitmq'; + displayName = 'RabbitMQ'; + documentationUrl = 'rabbitmq'; + properties: INodeProperties[] = [ { displayName: 'Hostname', diff --git a/packages/nodes-base/credentials/RaindropOAuth2Api.credentials.ts b/packages/nodes-base/credentials/RaindropOAuth2Api.credentials.ts index 08fe806cf9..d38dd95348 100644 --- a/packages/nodes-base/credentials/RaindropOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/RaindropOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class RaindropOAuth2Api implements ICredentialType { name = 'raindropOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Raindrop OAuth2 API'; + documentationUrl = 'raindrop'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/RedditOAuth2Api.credentials.ts b/packages/nodes-base/credentials/RedditOAuth2Api.credentials.ts index ff4c1af89b..e4cb456e92 100644 --- a/packages/nodes-base/credentials/RedditOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/RedditOAuth2Api.credentials.ts @@ -6,9 +6,13 @@ const scopes = ['identity', 'edit', 'history', 'mysubreddits', 'read', 'save', ' export class RedditOAuth2Api implements ICredentialType { name = 'redditOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Reddit OAuth2 API'; + documentationUrl = 'reddit'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/Redis.credentials.ts b/packages/nodes-base/credentials/Redis.credentials.ts index cddb70c078..ea00211cb6 100644 --- a/packages/nodes-base/credentials/Redis.credentials.ts +++ b/packages/nodes-base/credentials/Redis.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Redis implements ICredentialType { name = 'redis'; + displayName = 'Redis'; + documentationUrl = 'redis'; + properties: INodeProperties[] = [ { displayName: 'Password', diff --git a/packages/nodes-base/credentials/RocketchatApi.credentials.ts b/packages/nodes-base/credentials/RocketchatApi.credentials.ts index 2c76a53190..ccd0c4d49f 100644 --- a/packages/nodes-base/credentials/RocketchatApi.credentials.ts +++ b/packages/nodes-base/credentials/RocketchatApi.credentials.ts @@ -7,8 +7,11 @@ import { export class RocketchatApi implements ICredentialType { name = 'rocketchatApi'; + displayName = 'Rocket API'; + documentationUrl = 'rocketchat'; + properties: INodeProperties[] = [ { displayName: 'User ID', @@ -30,6 +33,7 @@ export class RocketchatApi implements ICredentialType { placeholder: 'https://n8n.rocket.chat', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -39,6 +43,7 @@ export class RocketchatApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials.domain}}', diff --git a/packages/nodes-base/credentials/RundeckApi.credentials.ts b/packages/nodes-base/credentials/RundeckApi.credentials.ts index bbfc7c3665..a264e34c5c 100644 --- a/packages/nodes-base/credentials/RundeckApi.credentials.ts +++ b/packages/nodes-base/credentials/RundeckApi.credentials.ts @@ -7,8 +7,11 @@ import { export class RundeckApi implements ICredentialType { name = 'rundeckApi'; + displayName = 'Rundeck API'; + documentationUrl = 'rundeck'; + properties: INodeProperties[] = [ { displayName: 'Url', diff --git a/packages/nodes-base/credentials/S3.credentials.ts b/packages/nodes-base/credentials/S3.credentials.ts index 562752e42a..80c7127b50 100644 --- a/packages/nodes-base/credentials/S3.credentials.ts +++ b/packages/nodes-base/credentials/S3.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class S3 implements ICredentialType { name = 's3'; + displayName = 'S3'; + documentationUrl = 's3'; + properties: INodeProperties[] = [ { displayName: 'S3 Endpoint', diff --git a/packages/nodes-base/credentials/SalesforceJwtApi.credentials.ts b/packages/nodes-base/credentials/SalesforceJwtApi.credentials.ts index 6bcc8fda7c..0f59d7e140 100644 --- a/packages/nodes-base/credentials/SalesforceJwtApi.credentials.ts +++ b/packages/nodes-base/credentials/SalesforceJwtApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SalesforceJwtApi implements ICredentialType { name = 'salesforceJwtApi'; + displayName = 'Salesforce JWT API'; + documentationUrl = 'salesforce'; + properties: INodeProperties[] = [ { displayName: 'Environment Type', diff --git a/packages/nodes-base/credentials/SalesforceOAuth2Api.credentials.ts b/packages/nodes-base/credentials/SalesforceOAuth2Api.credentials.ts index 21078e0f72..f405fd9951 100644 --- a/packages/nodes-base/credentials/SalesforceOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/SalesforceOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SalesforceOAuth2Api implements ICredentialType { name = 'salesforceOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Salesforce OAuth2 API'; + documentationUrl = 'salesforce'; + properties: INodeProperties[] = [ { displayName: 'Environment Type', diff --git a/packages/nodes-base/credentials/SalesmateApi.credentials.ts b/packages/nodes-base/credentials/SalesmateApi.credentials.ts index 333c645abd..760f1f0956 100644 --- a/packages/nodes-base/credentials/SalesmateApi.credentials.ts +++ b/packages/nodes-base/credentials/SalesmateApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SalesmateApi implements ICredentialType { name = 'salesmateApi'; + displayName = 'Salesmate API'; + documentationUrl = 'salesmate'; + properties: INodeProperties[] = [ { displayName: 'Session Token', diff --git a/packages/nodes-base/credentials/SeaTableApi.credentials.ts b/packages/nodes-base/credentials/SeaTableApi.credentials.ts index dda4870087..12dde25a72 100644 --- a/packages/nodes-base/credentials/SeaTableApi.credentials.ts +++ b/packages/nodes-base/credentials/SeaTableApi.credentials.ts @@ -5,17 +5,20 @@ import moment from 'moment-timezone'; // Get options for timezones const timezones: INodePropertyOptions[] = moment.tz .countries() - .reduce((timezones: INodePropertyOptions[], country: string) => { + .reduce((tz: INodePropertyOptions[], country: string) => { const zonesForCountry = moment.tz .zonesForCountry(country) .map((zone) => ({ value: zone, name: zone })); - return timezones.concat(zonesForCountry); + return tz.concat(zonesForCountry); }, []); export class SeaTableApi implements ICredentialType { name = 'seaTableApi'; + displayName = 'SeaTable API'; + documentationUrl = 'seaTable'; + properties: INodeProperties[] = [ { displayName: 'Environment', diff --git a/packages/nodes-base/credentials/SecurityScorecardApi.credentials.ts b/packages/nodes-base/credentials/SecurityScorecardApi.credentials.ts index 1248f85ac8..59857e4334 100644 --- a/packages/nodes-base/credentials/SecurityScorecardApi.credentials.ts +++ b/packages/nodes-base/credentials/SecurityScorecardApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SecurityScorecardApi implements ICredentialType { name = 'securityScorecardApi'; + displayName = 'SecurityScorecard API'; + documentationUrl = 'securityScorecard'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/SegmentApi.credentials.ts b/packages/nodes-base/credentials/SegmentApi.credentials.ts index 6cc84554d2..44804861e6 100644 --- a/packages/nodes-base/credentials/SegmentApi.credentials.ts +++ b/packages/nodes-base/credentials/SegmentApi.credentials.ts @@ -7,8 +7,11 @@ import { export class SegmentApi implements ICredentialType { name = 'segmentApi'; + displayName = 'Segment API'; + documentationUrl = 'segment'; + properties: INodeProperties[] = [ { displayName: 'Write Key', @@ -17,12 +20,13 @@ export class SegmentApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, ): Promise { const base64Key = Buffer.from(`${credentials.writekey}:`).toString('base64'); - requestOptions.headers!['Authorization'] = `Basic ${base64Key}`; + requestOptions.headers!.Authorization = `Basic ${base64Key}`; return requestOptions; } } diff --git a/packages/nodes-base/credentials/SendGridApi.credentials.ts b/packages/nodes-base/credentials/SendGridApi.credentials.ts index 70a1296806..1b8eea4f8a 100644 --- a/packages/nodes-base/credentials/SendGridApi.credentials.ts +++ b/packages/nodes-base/credentials/SendGridApi.credentials.ts @@ -7,8 +7,11 @@ import { export class SendGridApi implements ICredentialType { name = 'sendGridApi'; + displayName = 'SendGrid API'; + documentationUrl = 'sendgrid'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class SendGridApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/SendInBlueApi.credentials.ts b/packages/nodes-base/credentials/SendInBlueApi.credentials.ts index 3cb7a728ca..921c895c38 100644 --- a/packages/nodes-base/credentials/SendInBlueApi.credentials.ts +++ b/packages/nodes-base/credentials/SendInBlueApi.credentials.ts @@ -7,8 +7,11 @@ import { export class SendInBlueApi implements ICredentialType { name = 'sendInBlueApi'; + displayName = 'SendInBlue'; + documentationUrl = 'sendInBlueApi'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class SendInBlueApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class SendInBlueApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.sendinblue.com/v3', diff --git a/packages/nodes-base/credentials/SendyApi.credentials.ts b/packages/nodes-base/credentials/SendyApi.credentials.ts index e934cb9f1a..0daa2613f4 100644 --- a/packages/nodes-base/credentials/SendyApi.credentials.ts +++ b/packages/nodes-base/credentials/SendyApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SendyApi implements ICredentialType { name = 'sendyApi'; + displayName = 'Sendy API'; + documentationUrl = 'sendy'; + properties: INodeProperties[] = [ { displayName: 'URL', diff --git a/packages/nodes-base/credentials/SentryIoApi.credentials.ts b/packages/nodes-base/credentials/SentryIoApi.credentials.ts index 1ae684af6f..24b0c1305a 100644 --- a/packages/nodes-base/credentials/SentryIoApi.credentials.ts +++ b/packages/nodes-base/credentials/SentryIoApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SentryIoApi implements ICredentialType { name = 'sentryIoApi'; + displayName = 'Sentry.io API'; + documentationUrl = 'sentryIo'; + properties: INodeProperties[] = [ { displayName: 'Token', diff --git a/packages/nodes-base/credentials/SentryIoOAuth2Api.credentials.ts b/packages/nodes-base/credentials/SentryIoOAuth2Api.credentials.ts index 0ff089a59a..baa3846c7b 100644 --- a/packages/nodes-base/credentials/SentryIoOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/SentryIoOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SentryIoOAuth2Api implements ICredentialType { name = 'sentryIoOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Sentry.io OAuth2 API'; + documentationUrl = 'sentryIo'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/SentryIoServerApi.credentials.ts b/packages/nodes-base/credentials/SentryIoServerApi.credentials.ts index c9dac74b44..13859f2ac1 100644 --- a/packages/nodes-base/credentials/SentryIoServerApi.credentials.ts +++ b/packages/nodes-base/credentials/SentryIoServerApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SentryIoServerApi implements ICredentialType { name = 'sentryIoServerApi'; + displayName = 'Sentry.io Server API'; + documentationUrl = 'sentryIo'; + properties: INodeProperties[] = [ { displayName: 'Token', diff --git a/packages/nodes-base/credentials/ServiceNowBasicApi.credentials.ts b/packages/nodes-base/credentials/ServiceNowBasicApi.credentials.ts index 7fb51aa024..872b8be358 100644 --- a/packages/nodes-base/credentials/ServiceNowBasicApi.credentials.ts +++ b/packages/nodes-base/credentials/ServiceNowBasicApi.credentials.ts @@ -7,9 +7,13 @@ import { export class ServiceNowBasicApi implements ICredentialType { name = 'serviceNowBasicApi'; + extends = ['httpBasicAuth']; + displayName = 'ServiceNow Basic Auth API'; + documentationUrl = 'serviceNow'; + properties: INodeProperties[] = [ { displayName: 'User', diff --git a/packages/nodes-base/credentials/ServiceNowOAuth2Api.credentials.ts b/packages/nodes-base/credentials/ServiceNowOAuth2Api.credentials.ts index 9157b2e982..2e08375ed2 100644 --- a/packages/nodes-base/credentials/ServiceNowOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/ServiceNowOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ServiceNowOAuth2Api implements ICredentialType { name = 'serviceNowOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'ServiceNow OAuth2 API'; + documentationUrl = 'serviceNow'; + properties: INodeProperties[] = [ { displayName: 'Subdomain', diff --git a/packages/nodes-base/credentials/Sftp.credentials.ts b/packages/nodes-base/credentials/Sftp.credentials.ts index f63fb8dcc7..6b74ae5a03 100644 --- a/packages/nodes-base/credentials/Sftp.credentials.ts +++ b/packages/nodes-base/credentials/Sftp.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Sftp implements ICredentialType { name = 'sftp'; + displayName = 'SFTP'; + documentationUrl = 'ftp'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/ShopifyAccessTokenApi.credentials.ts b/packages/nodes-base/credentials/ShopifyAccessTokenApi.credentials.ts index db1637abf5..e55eeeede4 100644 --- a/packages/nodes-base/credentials/ShopifyAccessTokenApi.credentials.ts +++ b/packages/nodes-base/credentials/ShopifyAccessTokenApi.credentials.ts @@ -7,8 +7,11 @@ import { export class ShopifyAccessTokenApi implements ICredentialType { name = 'shopifyAccessTokenApi'; + displayName = 'Shopify Access Token API'; + documentationUrl = 'shopify'; + properties: INodeProperties[] = [ { displayName: 'Shop Subdomain', @@ -35,6 +38,7 @@ export class ShopifyAccessTokenApi implements ICredentialType { description: 'Secret key needed to verify the webhook when using Shopify Trigger node', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -43,6 +47,7 @@ export class ShopifyAccessTokenApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '=https://{{$credentials?.shopSubdomain}}.myshopify.com/admin/api/2019-10', diff --git a/packages/nodes-base/credentials/ShopifyApi.credentials.ts b/packages/nodes-base/credentials/ShopifyApi.credentials.ts index 555ec11f87..2cade6034e 100644 --- a/packages/nodes-base/credentials/ShopifyApi.credentials.ts +++ b/packages/nodes-base/credentials/ShopifyApi.credentials.ts @@ -9,8 +9,11 @@ import { export class ShopifyApi implements ICredentialType { name = 'shopifyApi'; + displayName = 'Shopify API'; + documentationUrl = 'shopify'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -43,6 +46,7 @@ export class ShopifyApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, diff --git a/packages/nodes-base/credentials/ShopifyOAuth2Api.credentials.ts b/packages/nodes-base/credentials/ShopifyOAuth2Api.credentials.ts index 46ced58570..d5c4df456d 100644 --- a/packages/nodes-base/credentials/ShopifyOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/ShopifyOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ShopifyOAuth2Api implements ICredentialType { name = 'shopifyOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Shopify OAuth2 API'; + documentationUrl = 'shopify'; + properties: INodeProperties[] = [ { displayName: 'Shop Subdomain', diff --git a/packages/nodes-base/credentials/Signl4Api.credentials.ts b/packages/nodes-base/credentials/Signl4Api.credentials.ts index 5d64d638fa..bf606b1bd5 100644 --- a/packages/nodes-base/credentials/Signl4Api.credentials.ts +++ b/packages/nodes-base/credentials/Signl4Api.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Signl4Api implements ICredentialType { name = 'signl4Api'; + displayName = 'SIGNL4 Webhook'; + documentationUrl = 'signl4'; + properties: INodeProperties[] = [ { displayName: 'Team Secret', diff --git a/packages/nodes-base/credentials/SlackApi.credentials.ts b/packages/nodes-base/credentials/SlackApi.credentials.ts index cccee24bac..3d8a448419 100644 --- a/packages/nodes-base/credentials/SlackApi.credentials.ts +++ b/packages/nodes-base/credentials/SlackApi.credentials.ts @@ -7,8 +7,11 @@ import { export class SlackApi implements ICredentialType { name = 'slackApi'; + displayName = 'Slack API'; + documentationUrl = 'slack'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/SlackOAuth2Api.credentials.ts b/packages/nodes-base/credentials/SlackOAuth2Api.credentials.ts index 2a97a8dac7..2434aa33c0 100644 --- a/packages/nodes-base/credentials/SlackOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/SlackOAuth2Api.credentials.ts @@ -22,9 +22,13 @@ const userScopes = [ export class SlackOAuth2Api implements ICredentialType { name = 'slackOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Slack OAuth2 API'; + documentationUrl = 'slack'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/Sms77Api.credentials.ts b/packages/nodes-base/credentials/Sms77Api.credentials.ts index ab9509532e..99c948b37e 100644 --- a/packages/nodes-base/credentials/Sms77Api.credentials.ts +++ b/packages/nodes-base/credentials/Sms77Api.credentials.ts @@ -7,8 +7,11 @@ import { export class Sms77Api implements ICredentialType { name = 'sms77Api'; + displayName = 'Sms77 API'; + documentationUrl = 'sms77'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -18,6 +21,7 @@ export class Sms77Api implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class Sms77Api implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://gateway.sms77.io/api', diff --git a/packages/nodes-base/credentials/Smtp.credentials.ts b/packages/nodes-base/credentials/Smtp.credentials.ts index c40ba546e9..b5b9e8fad0 100644 --- a/packages/nodes-base/credentials/Smtp.credentials.ts +++ b/packages/nodes-base/credentials/Smtp.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Smtp implements ICredentialType { name = 'smtp'; + displayName = 'SMTP'; + documentationUrl = 'smtp'; + properties: INodeProperties[] = [ { displayName: 'User', diff --git a/packages/nodes-base/credentials/Snowflake.credentials.ts b/packages/nodes-base/credentials/Snowflake.credentials.ts index 878477a375..6d239cedca 100644 --- a/packages/nodes-base/credentials/Snowflake.credentials.ts +++ b/packages/nodes-base/credentials/Snowflake.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class Snowflake implements ICredentialType { name = 'snowflake'; + displayName = 'Snowflake'; + documentationUrl = 'snowflake'; + properties: INodeProperties[] = [ { displayName: 'Account', diff --git a/packages/nodes-base/credentials/SplunkApi.credentials.ts b/packages/nodes-base/credentials/SplunkApi.credentials.ts index 4c447d62ea..1b55e54d81 100644 --- a/packages/nodes-base/credentials/SplunkApi.credentials.ts +++ b/packages/nodes-base/credentials/SplunkApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SplunkApi implements ICredentialType { name = 'splunkApi'; + displayName = 'Splunk API'; + documentationUrl = 'splunk'; + properties: INodeProperties[] = [ { displayName: 'Auth Token', diff --git a/packages/nodes-base/credentials/SpontitApi.credentials.ts b/packages/nodes-base/credentials/SpontitApi.credentials.ts index 9ca35d79bb..1784f70374 100644 --- a/packages/nodes-base/credentials/SpontitApi.credentials.ts +++ b/packages/nodes-base/credentials/SpontitApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SpontitApi implements ICredentialType { name = 'spontitApi'; + displayName = 'Spontit API'; + documentationUrl = 'spontit'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/SpotifyOAuth2Api.credentials.ts b/packages/nodes-base/credentials/SpotifyOAuth2Api.credentials.ts index 0f0cc09cbb..95242aff9d 100644 --- a/packages/nodes-base/credentials/SpotifyOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/SpotifyOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SpotifyOAuth2Api implements ICredentialType { name = 'spotifyOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Spotify OAuth2 API'; + documentationUrl = 'spotify'; + properties: INodeProperties[] = [ { displayName: 'Spotify Server', diff --git a/packages/nodes-base/credentials/SshPassword.credentials.ts b/packages/nodes-base/credentials/SshPassword.credentials.ts index cde3d0d46e..4cbb92e56f 100644 --- a/packages/nodes-base/credentials/SshPassword.credentials.ts +++ b/packages/nodes-base/credentials/SshPassword.credentials.ts @@ -2,7 +2,9 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SshPassword implements ICredentialType { name = 'sshPassword'; + displayName = 'SSH Password'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/SshPrivateKey.credentials.ts b/packages/nodes-base/credentials/SshPrivateKey.credentials.ts index 9030ec5771..9ec9213ef1 100644 --- a/packages/nodes-base/credentials/SshPrivateKey.credentials.ts +++ b/packages/nodes-base/credentials/SshPrivateKey.credentials.ts @@ -2,7 +2,9 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SshPrivateKey implements ICredentialType { name = 'sshPrivateKey'; + displayName = 'SSH Private Key'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/StackbyApi.credentials.ts b/packages/nodes-base/credentials/StackbyApi.credentials.ts index 05d537b6d2..3867fc8fbf 100644 --- a/packages/nodes-base/credentials/StackbyApi.credentials.ts +++ b/packages/nodes-base/credentials/StackbyApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class StackbyApi implements ICredentialType { name = 'stackbyApi'; + displayName = 'Stackby API'; + documentationUrl = 'stackby'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/StoryblokContentApi.credentials.ts b/packages/nodes-base/credentials/StoryblokContentApi.credentials.ts index 9959205f83..dded8a3970 100644 --- a/packages/nodes-base/credentials/StoryblokContentApi.credentials.ts +++ b/packages/nodes-base/credentials/StoryblokContentApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class StoryblokContentApi implements ICredentialType { name = 'storyblokContentApi'; + displayName = 'Storyblok Content API'; + documentationUrl = 'storyblok'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/StoryblokManagementApi.credentials.ts b/packages/nodes-base/credentials/StoryblokManagementApi.credentials.ts index 3d5407d161..166346a2e3 100644 --- a/packages/nodes-base/credentials/StoryblokManagementApi.credentials.ts +++ b/packages/nodes-base/credentials/StoryblokManagementApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class StoryblokManagementApi implements ICredentialType { name = 'storyblokManagementApi'; + displayName = 'Storyblok Management API'; + documentationUrl = 'storyblok'; + properties: INodeProperties[] = [ { displayName: 'Personal Access Token', diff --git a/packages/nodes-base/credentials/StrapiApi.credentials.ts b/packages/nodes-base/credentials/StrapiApi.credentials.ts index bddb4c75d2..a89120efd5 100644 --- a/packages/nodes-base/credentials/StrapiApi.credentials.ts +++ b/packages/nodes-base/credentials/StrapiApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class StrapiApi implements ICredentialType { name = 'strapiApi'; + displayName = 'Strapi API'; + documentationUrl = 'strapi'; + properties: INodeProperties[] = [ { displayName: 'Email', diff --git a/packages/nodes-base/credentials/StravaOAuth2Api.credentials.ts b/packages/nodes-base/credentials/StravaOAuth2Api.credentials.ts index 1af9613ff6..b5d8925481 100644 --- a/packages/nodes-base/credentials/StravaOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/StravaOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class StravaOAuth2Api implements ICredentialType { name = 'stravaOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Strava OAuth2 API'; + documentationUrl = 'strava'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/StripeApi.credentials.ts b/packages/nodes-base/credentials/StripeApi.credentials.ts index 84d25c2dc4..8f86c3a6b4 100644 --- a/packages/nodes-base/credentials/StripeApi.credentials.ts +++ b/packages/nodes-base/credentials/StripeApi.credentials.ts @@ -7,8 +7,11 @@ import { export class StripeApi implements ICredentialType { name = 'stripeApi'; + displayName = 'Stripe API'; + documentationUrl = 'stripe'; + properties: INodeProperties[] = [ { displayName: 'Secret Key', @@ -17,6 +20,7 @@ export class StripeApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -25,6 +29,7 @@ export class StripeApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.stripe.com/v1', diff --git a/packages/nodes-base/credentials/SupabaseApi.credentials.ts b/packages/nodes-base/credentials/SupabaseApi.credentials.ts index e169d781b0..c90dd10571 100644 --- a/packages/nodes-base/credentials/SupabaseApi.credentials.ts +++ b/packages/nodes-base/credentials/SupabaseApi.credentials.ts @@ -7,8 +7,11 @@ import { export class SupabaseApi implements ICredentialType { name = 'supabaseApi'; + displayName = 'Supabase API'; + documentationUrl = 'supabase'; + properties: INodeProperties[] = [ { displayName: 'Host', @@ -24,6 +27,7 @@ export class SupabaseApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -33,6 +37,7 @@ export class SupabaseApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials.host}}/rest/v1', diff --git a/packages/nodes-base/credentials/SurveyMonkeyApi.credentials.ts b/packages/nodes-base/credentials/SurveyMonkeyApi.credentials.ts index 2a74af12ce..546dbf646a 100644 --- a/packages/nodes-base/credentials/SurveyMonkeyApi.credentials.ts +++ b/packages/nodes-base/credentials/SurveyMonkeyApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SurveyMonkeyApi implements ICredentialType { name = 'surveyMonkeyApi'; + displayName = 'SurveyMonkey API'; + documentationUrl = 'surveyMonkey'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/SurveyMonkeyOAuth2Api.credentials.ts b/packages/nodes-base/credentials/SurveyMonkeyOAuth2Api.credentials.ts index d694188de0..5403e46221 100644 --- a/packages/nodes-base/credentials/SurveyMonkeyOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/SurveyMonkeyOAuth2Api.credentials.ts @@ -11,9 +11,13 @@ const scopes = [ export class SurveyMonkeyOAuth2Api implements ICredentialType { name = 'surveyMonkeyOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'SurveyMonkey OAuth2 API'; + documentationUrl = 'surveyMonkey'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/SyncroMspApi.credentials.ts b/packages/nodes-base/credentials/SyncroMspApi.credentials.ts index a779ed0513..e90b687852 100644 --- a/packages/nodes-base/credentials/SyncroMspApi.credentials.ts +++ b/packages/nodes-base/credentials/SyncroMspApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class SyncroMspApi implements ICredentialType { name = 'syncroMspApi'; + displayName = 'SyncroMSP API'; + documentationUrl = 'syncromsp'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/TaigaApi.credentials.ts b/packages/nodes-base/credentials/TaigaApi.credentials.ts index 3307cc9f7e..ab7470e80f 100644 --- a/packages/nodes-base/credentials/TaigaApi.credentials.ts +++ b/packages/nodes-base/credentials/TaigaApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class TaigaApi implements ICredentialType { name = 'taigaApi'; + displayName = 'Taiga API'; + documentationUrl = 'taiga'; + properties: INodeProperties[] = [ { displayName: 'Username', diff --git a/packages/nodes-base/credentials/TapfiliateApi.credentials.ts b/packages/nodes-base/credentials/TapfiliateApi.credentials.ts index 458d9fa0ef..ead37aa755 100644 --- a/packages/nodes-base/credentials/TapfiliateApi.credentials.ts +++ b/packages/nodes-base/credentials/TapfiliateApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class TapfiliateApi implements ICredentialType { name = 'tapfiliateApi'; + displayName = 'Tapfiliate API'; + documentationUrl = 'tapfiliate'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/TelegramApi.credentials.ts b/packages/nodes-base/credentials/TelegramApi.credentials.ts index 8de7055d57..6c202b652f 100644 --- a/packages/nodes-base/credentials/TelegramApi.credentials.ts +++ b/packages/nodes-base/credentials/TelegramApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-wo export class TelegramApi implements ICredentialType { name = 'telegramApi'; + displayName = 'Telegram API'; + documentationUrl = 'telegram'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/TheHiveApi.credentials.ts b/packages/nodes-base/credentials/TheHiveApi.credentials.ts index 1be0c4430c..ac0a0951ca 100644 --- a/packages/nodes-base/credentials/TheHiveApi.credentials.ts +++ b/packages/nodes-base/credentials/TheHiveApi.credentials.ts @@ -7,8 +7,11 @@ import { export class TheHiveApi implements ICredentialType { name = 'theHiveApi'; + displayName = 'The Hive API'; + documentationUrl = 'theHive'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -51,6 +54,7 @@ export class TheHiveApi implements ICredentialType { default: false, }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -59,6 +63,7 @@ export class TheHiveApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: `={{$credentials?.url}}`, diff --git a/packages/nodes-base/credentials/TimescaleDb.credentials.ts b/packages/nodes-base/credentials/TimescaleDb.credentials.ts index 234c4c3920..599a311a24 100644 --- a/packages/nodes-base/credentials/TimescaleDb.credentials.ts +++ b/packages/nodes-base/credentials/TimescaleDb.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class TimescaleDb implements ICredentialType { name = 'timescaleDb'; + displayName = 'TimescaleDB'; + documentationUrl = 'timescaleDb'; + properties: INodeProperties[] = [ { displayName: 'Host', diff --git a/packages/nodes-base/credentials/TodoistApi.credentials.ts b/packages/nodes-base/credentials/TodoistApi.credentials.ts index a8a8f34410..2c96f5024d 100644 --- a/packages/nodes-base/credentials/TodoistApi.credentials.ts +++ b/packages/nodes-base/credentials/TodoistApi.credentials.ts @@ -6,8 +6,11 @@ import { } from 'n8n-workflow'; export class TodoistApi implements ICredentialType { name = 'todoistApi'; + displayName = 'Todoist API'; + documentationUrl = 'todoist'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/TodoistOAuth2Api.credentials.ts b/packages/nodes-base/credentials/TodoistOAuth2Api.credentials.ts index 75f1c77c43..15b6bd2cd3 100644 --- a/packages/nodes-base/credentials/TodoistOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/TodoistOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class TodoistOAuth2Api implements ICredentialType { name = 'todoistOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Todoist OAuth2 API'; + documentationUrl = 'todoist'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/TogglApi.credentials.ts b/packages/nodes-base/credentials/TogglApi.credentials.ts index b33299c432..06a7942545 100644 --- a/packages/nodes-base/credentials/TogglApi.credentials.ts +++ b/packages/nodes-base/credentials/TogglApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class TogglApi implements ICredentialType { name = 'togglApi'; + displayName = 'Toggl API'; + documentationUrl = 'toggl'; + properties: INodeProperties[] = [ { displayName: 'Username', diff --git a/packages/nodes-base/credentials/TravisCiApi.credentials.ts b/packages/nodes-base/credentials/TravisCiApi.credentials.ts index f4f0d66033..51965760f1 100644 --- a/packages/nodes-base/credentials/TravisCiApi.credentials.ts +++ b/packages/nodes-base/credentials/TravisCiApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class TravisCiApi implements ICredentialType { name = 'travisCiApi'; + displayName = 'Travis API'; + documentationUrl = 'travisCi'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/TrelloApi.credentials.ts b/packages/nodes-base/credentials/TrelloApi.credentials.ts index ee33c90d43..142e25e6aa 100644 --- a/packages/nodes-base/credentials/TrelloApi.credentials.ts +++ b/packages/nodes-base/credentials/TrelloApi.credentials.ts @@ -8,8 +8,11 @@ import { export class TrelloApi implements ICredentialType { name = 'trelloApi'; + displayName = 'Trello API'; + documentationUrl = 'trello'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -45,6 +48,7 @@ export class TrelloApi implements ICredentialType { }; return requestOptions; } + test: ICredentialTestRequest = { request: { baseURL: 'https://api.trello.com', diff --git a/packages/nodes-base/credentials/TwakeCloudApi.credentials.ts b/packages/nodes-base/credentials/TwakeCloudApi.credentials.ts index 760432b41e..e529de0029 100644 --- a/packages/nodes-base/credentials/TwakeCloudApi.credentials.ts +++ b/packages/nodes-base/credentials/TwakeCloudApi.credentials.ts @@ -7,8 +7,11 @@ import { export class TwakeCloudApi implements ICredentialType { name = 'twakeCloudApi'; + displayName = 'Twake Cloud API'; + documentationUrl = 'twake'; + properties: INodeProperties[] = [ { displayName: 'Workspace Key', diff --git a/packages/nodes-base/credentials/TwakeServerApi.credentials.ts b/packages/nodes-base/credentials/TwakeServerApi.credentials.ts index 561a592eee..0e1005d8d5 100644 --- a/packages/nodes-base/credentials/TwakeServerApi.credentials.ts +++ b/packages/nodes-base/credentials/TwakeServerApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class TwakeServerApi implements ICredentialType { name = 'twakeServerApi'; + displayName = 'Twake Server API'; + documentationUrl = 'twake'; + properties: INodeProperties[] = [ { displayName: 'Host URL', diff --git a/packages/nodes-base/credentials/TwilioApi.credentials.ts b/packages/nodes-base/credentials/TwilioApi.credentials.ts index e142244d9a..6046eb3865 100644 --- a/packages/nodes-base/credentials/TwilioApi.credentials.ts +++ b/packages/nodes-base/credentials/TwilioApi.credentials.ts @@ -2,8 +2,11 @@ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-work export class TwilioApi implements ICredentialType { name = 'twilioApi'; + displayName = 'Twilio API'; + documentationUrl = 'twilio'; + properties: INodeProperties[] = [ { displayName: 'Auth Type', diff --git a/packages/nodes-base/credentials/TwistOAuth2Api.credentials.ts b/packages/nodes-base/credentials/TwistOAuth2Api.credentials.ts index 8a64ab5eb2..a54e143352 100644 --- a/packages/nodes-base/credentials/TwistOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/TwistOAuth2Api.credentials.ts @@ -11,9 +11,13 @@ const scopes = [ export class TwistOAuth2Api implements ICredentialType { name = 'twistOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Twist OAuth2 API'; + documentationUrl = 'twist'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/TwitterOAuth1Api.credentials.ts b/packages/nodes-base/credentials/TwitterOAuth1Api.credentials.ts index f168c17ee5..5afa0ca474 100644 --- a/packages/nodes-base/credentials/TwitterOAuth1Api.credentials.ts +++ b/packages/nodes-base/credentials/TwitterOAuth1Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class TwitterOAuth1Api implements ICredentialType { name = 'twitterOAuth1Api'; + extends = ['oAuth1Api']; + displayName = 'Twitter OAuth API'; + documentationUrl = 'twitter'; + properties: INodeProperties[] = [ { displayName: 'Request Token URL', diff --git a/packages/nodes-base/credentials/TypeformApi.credentials.ts b/packages/nodes-base/credentials/TypeformApi.credentials.ts index 60f2a36cdf..d68ae60d58 100644 --- a/packages/nodes-base/credentials/TypeformApi.credentials.ts +++ b/packages/nodes-base/credentials/TypeformApi.credentials.ts @@ -7,8 +7,11 @@ import { export class TypeformApi implements ICredentialType { name = 'typeformApi'; + displayName = 'Typeform API'; + documentationUrl = 'typeform'; + properties: INodeProperties[] = [ { displayName: 'Access Token', @@ -18,6 +21,7 @@ export class TypeformApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/TypeformOAuth2Api.credentials.ts b/packages/nodes-base/credentials/TypeformOAuth2Api.credentials.ts index 3bc6f863e5..302693d2b4 100644 --- a/packages/nodes-base/credentials/TypeformOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/TypeformOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['webhooks:write', 'webhooks:read', 'forms:read']; export class TypeformOAuth2Api implements ICredentialType { name = 'typeformOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Typeform OAuth2 API'; + documentationUrl = 'typeform'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/UProcApi.credentials.ts b/packages/nodes-base/credentials/UProcApi.credentials.ts index fe4d4de5f1..926d574147 100644 --- a/packages/nodes-base/credentials/UProcApi.credentials.ts +++ b/packages/nodes-base/credentials/UProcApi.credentials.ts @@ -8,8 +8,11 @@ import { export class UProcApi implements ICredentialType { name = 'uprocApi'; + displayName = 'uProc API'; + documentationUrl = 'uProc'; + properties: INodeProperties[] = [ { displayName: 'Email', @@ -26,6 +29,7 @@ export class UProcApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -37,6 +41,7 @@ export class UProcApi implements ICredentialType { }; return requestOptions; } + test: ICredentialTestRequest = { request: { baseURL: 'https://api.uproc.io/api/v2', diff --git a/packages/nodes-base/credentials/UnleashedSoftwareApi.credentials.ts b/packages/nodes-base/credentials/UnleashedSoftwareApi.credentials.ts index c65bf9b5e2..a57c0ceeb2 100644 --- a/packages/nodes-base/credentials/UnleashedSoftwareApi.credentials.ts +++ b/packages/nodes-base/credentials/UnleashedSoftwareApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class UnleashedSoftwareApi implements ICredentialType { name = 'unleashedSoftwareApi'; + displayName = 'Unleashed API'; + documentationUrl = 'unleashedSoftware'; + properties: INodeProperties[] = [ { displayName: 'API ID', diff --git a/packages/nodes-base/credentials/UpleadApi.credentials.ts b/packages/nodes-base/credentials/UpleadApi.credentials.ts index 63bb0356ec..e475320544 100644 --- a/packages/nodes-base/credentials/UpleadApi.credentials.ts +++ b/packages/nodes-base/credentials/UpleadApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class UpleadApi implements ICredentialType { name = 'upleadApi'; + displayName = 'Uplead API'; + documentationUrl = 'uplead'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/UptimeRobotApi.credentials.ts b/packages/nodes-base/credentials/UptimeRobotApi.credentials.ts index 8cc516fec1..737955fba3 100644 --- a/packages/nodes-base/credentials/UptimeRobotApi.credentials.ts +++ b/packages/nodes-base/credentials/UptimeRobotApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class UptimeRobotApi implements ICredentialType { name = 'uptimeRobotApi'; + displayName = 'Uptime Robot API'; + documentationUrl = 'uptimeRobot'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts b/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts index e36a6e8c94..3816308663 100644 --- a/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts +++ b/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts @@ -7,8 +7,11 @@ import { export class UrlScanIoApi implements ICredentialType { name = 'urlScanIoApi'; + displayName = 'urlscan.io API'; + documentationUrl = 'urlScanIo'; + properties: INodeProperties[] = [ { displayName: 'API Key', @@ -19,6 +22,7 @@ export class UrlScanIoApi implements ICredentialType { required: true, }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { diff --git a/packages/nodes-base/credentials/VenafiTlsProtectCloudApi.credentials.ts b/packages/nodes-base/credentials/VenafiTlsProtectCloudApi.credentials.ts index 8015c8ccc5..80bce02628 100644 --- a/packages/nodes-base/credentials/VenafiTlsProtectCloudApi.credentials.ts +++ b/packages/nodes-base/credentials/VenafiTlsProtectCloudApi.credentials.ts @@ -7,7 +7,9 @@ import { export class VenafiTlsProtectCloudApi implements ICredentialType { name = 'venafiTlsProtectCloudApi'; + displayName = 'Venafi TLS Protect Cloud'; + properties = [ { displayName: 'API Key', @@ -16,6 +18,7 @@ export class VenafiTlsProtectCloudApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -24,6 +27,7 @@ export class VenafiTlsProtectCloudApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.venafi.cloud', diff --git a/packages/nodes-base/credentials/VenafiTlsProtectDatacenterApi.credentials.ts b/packages/nodes-base/credentials/VenafiTlsProtectDatacenterApi.credentials.ts index dddd67352c..6f94b32937 100644 --- a/packages/nodes-base/credentials/VenafiTlsProtectDatacenterApi.credentials.ts +++ b/packages/nodes-base/credentials/VenafiTlsProtectDatacenterApi.credentials.ts @@ -9,7 +9,9 @@ import { export class VenafiTlsProtectDatacenterApi implements ICredentialType { name = 'venafiTlsProtectDatacenterApi'; + displayName = 'Venafi TLS Protect Datacenter API'; + properties: INodeProperties[] = [ { displayName: 'Domain', diff --git a/packages/nodes-base/credentials/VeroApi.credentials.ts b/packages/nodes-base/credentials/VeroApi.credentials.ts index 5ba870c1d0..f5ecfb8779 100644 --- a/packages/nodes-base/credentials/VeroApi.credentials.ts +++ b/packages/nodes-base/credentials/VeroApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class VeroApi implements ICredentialType { name = 'veroApi'; + displayName = 'Vero API'; + documentationUrl = 'vero'; + properties: INodeProperties[] = [ { displayName: 'Auth Token', diff --git a/packages/nodes-base/credentials/VonageApi.credentials.ts b/packages/nodes-base/credentials/VonageApi.credentials.ts index 0dcad455e5..8f9bcb542f 100644 --- a/packages/nodes-base/credentials/VonageApi.credentials.ts +++ b/packages/nodes-base/credentials/VonageApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class VonageApi implements ICredentialType { name = 'vonageApi'; + displayName = 'Vonage API'; + documentationUrl = 'vonage'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/WebflowApi.credentials.ts b/packages/nodes-base/credentials/WebflowApi.credentials.ts index 2454f7ccf8..b36fc23694 100644 --- a/packages/nodes-base/credentials/WebflowApi.credentials.ts +++ b/packages/nodes-base/credentials/WebflowApi.credentials.ts @@ -7,8 +7,11 @@ import { export class WebflowApi implements ICredentialType { name = 'webflowApi'; + displayName = 'Webflow API'; + documentationUrl = 'webflow'; + properties: INodeProperties[] = [ { displayName: 'Access Token', @@ -18,6 +21,7 @@ export class WebflowApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class WebflowApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.webflow.com', diff --git a/packages/nodes-base/credentials/WebflowOAuth2Api.credentials.ts b/packages/nodes-base/credentials/WebflowOAuth2Api.credentials.ts index 357bfbaccf..8ed9b0e691 100644 --- a/packages/nodes-base/credentials/WebflowOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/WebflowOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class WebflowOAuth2Api implements ICredentialType { name = 'webflowOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Webflow OAuth2 API'; + documentationUrl = 'webflow'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/WekanApi.credentials.ts b/packages/nodes-base/credentials/WekanApi.credentials.ts index bac7578435..9b6e234d05 100644 --- a/packages/nodes-base/credentials/WekanApi.credentials.ts +++ b/packages/nodes-base/credentials/WekanApi.credentials.ts @@ -9,8 +9,11 @@ import { export class WekanApi implements ICredentialType { name = 'wekanApi'; + displayName = 'Wekan API'; + documentationUrl = 'wekan'; + properties: INodeProperties[] = [ { displayName: 'Username', diff --git a/packages/nodes-base/credentials/WhatsAppApi.credentials.ts b/packages/nodes-base/credentials/WhatsAppApi.credentials.ts index 6ac5e0bbdc..e3ed18ea5b 100644 --- a/packages/nodes-base/credentials/WhatsAppApi.credentials.ts +++ b/packages/nodes-base/credentials/WhatsAppApi.credentials.ts @@ -7,8 +7,11 @@ import { export class WhatsAppApi implements ICredentialType { name = 'whatsAppApi'; + displayName = 'WhatsApp API'; + documentationUrl = 'whatsApp'; + properties: INodeProperties[] = [ { displayName: 'Access Token', diff --git a/packages/nodes-base/credentials/WiseApi.credentials.ts b/packages/nodes-base/credentials/WiseApi.credentials.ts index 63986c085c..cdeb07b3da 100644 --- a/packages/nodes-base/credentials/WiseApi.credentials.ts +++ b/packages/nodes-base/credentials/WiseApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class WiseApi implements ICredentialType { name = 'wiseApi'; + displayName = 'Wise API'; + documentationUrl = 'wise'; + properties: INodeProperties[] = [ { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/WooCommerceApi.credentials.ts b/packages/nodes-base/credentials/WooCommerceApi.credentials.ts index fd3c7a1d94..03f94d719e 100644 --- a/packages/nodes-base/credentials/WooCommerceApi.credentials.ts +++ b/packages/nodes-base/credentials/WooCommerceApi.credentials.ts @@ -8,8 +8,11 @@ import { export class WooCommerceApi implements ICredentialType { name = 'wooCommerceApi'; + displayName = 'WooCommerce API'; + documentationUrl = 'wooCommerce'; + properties: INodeProperties[] = [ { displayName: 'Consumer Key', @@ -39,6 +42,7 @@ export class WooCommerceApi implements ICredentialType { 'Whether credentials should be included in the query. Occasionally, some servers may not parse the Authorization header correctly (if you see a “Consumer key is missing” error when authenticating over SSL, you have a server issue). In this case, you may provide the consumer key/secret as query string parameters instead.', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -57,6 +61,7 @@ export class WooCommerceApi implements ICredentialType { } return requestOptions; } + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials.url}}/wp-json/wc/v3', diff --git a/packages/nodes-base/credentials/WordpressApi.credentials.ts b/packages/nodes-base/credentials/WordpressApi.credentials.ts index b83de9571a..59f3bd3588 100644 --- a/packages/nodes-base/credentials/WordpressApi.credentials.ts +++ b/packages/nodes-base/credentials/WordpressApi.credentials.ts @@ -7,8 +7,11 @@ import { export class WordpressApi implements ICredentialType { name = 'wordpressApi'; + displayName = 'Wordpress API'; + documentationUrl = 'wordpress'; + properties: INodeProperties[] = [ { displayName: 'Username', @@ -33,6 +36,7 @@ export class WordpressApi implements ICredentialType { placeholder: 'https://example.com', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -42,6 +46,7 @@ export class WordpressApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: '={{$credentials?.url}}/wp-json/wp/v2', diff --git a/packages/nodes-base/credentials/WorkableApi.credentials.ts b/packages/nodes-base/credentials/WorkableApi.credentials.ts index 0518229d2f..8457652a8b 100644 --- a/packages/nodes-base/credentials/WorkableApi.credentials.ts +++ b/packages/nodes-base/credentials/WorkableApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class WorkableApi implements ICredentialType { name = 'workableApi'; + displayName = 'Workable API'; + documentationUrl = 'workable'; + properties: INodeProperties[] = [ { displayName: 'Subdomain', diff --git a/packages/nodes-base/credentials/WufooApi.credentials.ts b/packages/nodes-base/credentials/WufooApi.credentials.ts index fa2c29847f..ddf420d0a3 100644 --- a/packages/nodes-base/credentials/WufooApi.credentials.ts +++ b/packages/nodes-base/credentials/WufooApi.credentials.ts @@ -7,8 +7,11 @@ import { export class WufooApi implements ICredentialType { name = 'wufooApi'; + displayName = 'Wufoo API'; + documentationUrl = 'wufoo'; + properties: INodeProperties[] = [ { displayName: 'API Key', diff --git a/packages/nodes-base/credentials/XeroOAuth2Api.credentials.ts b/packages/nodes-base/credentials/XeroOAuth2Api.credentials.ts index 912203261a..fe012bae16 100644 --- a/packages/nodes-base/credentials/XeroOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/XeroOAuth2Api.credentials.ts @@ -9,9 +9,13 @@ const scopes = [ export class XeroOAuth2Api implements ICredentialType { name = 'xeroOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Xero OAuth2 API'; + documentationUrl = 'xero'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/YouTubeOAuth2Api.credentials.ts b/packages/nodes-base/credentials/YouTubeOAuth2Api.credentials.ts index ba0b2c7466..91fa0a8b63 100644 --- a/packages/nodes-base/credentials/YouTubeOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/YouTubeOAuth2Api.credentials.ts @@ -11,10 +11,15 @@ const scopes = [ export class YouTubeOAuth2Api implements ICredentialType { name = 'youTubeOAuth2Api'; + icon = 'node:n8n-nodes-base.youTube'; + extends = ['googleOAuth2Api']; + displayName = 'YouTube OAuth2 API'; + documentationUrl = 'google'; + properties: INodeProperties[] = [ { displayName: 'Scope', diff --git a/packages/nodes-base/credentials/YourlsApi.credentials.ts b/packages/nodes-base/credentials/YourlsApi.credentials.ts index e914af0759..062128b51c 100644 --- a/packages/nodes-base/credentials/YourlsApi.credentials.ts +++ b/packages/nodes-base/credentials/YourlsApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class YourlsApi implements ICredentialType { name = 'yourlsApi'; + displayName = 'Yourls API'; + documentationUrl = 'yourls'; + properties: INodeProperties[] = [ { displayName: 'Signature', diff --git a/packages/nodes-base/credentials/ZammadBasicAuthApi.credentials.ts b/packages/nodes-base/credentials/ZammadBasicAuthApi.credentials.ts index 56b048c3f5..bc8aa16cf3 100644 --- a/packages/nodes-base/credentials/ZammadBasicAuthApi.credentials.ts +++ b/packages/nodes-base/credentials/ZammadBasicAuthApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ZammadBasicAuthApi implements ICredentialType { name = 'zammadBasicAuthApi'; + displayName = 'Zammad Basic Auth API'; + documentationUrl = 'zammad'; + properties: INodeProperties[] = [ { displayName: 'Base URL', diff --git a/packages/nodes-base/credentials/ZammadTokenAuthApi.credentials.ts b/packages/nodes-base/credentials/ZammadTokenAuthApi.credentials.ts index 26e795b71e..55c1c90945 100644 --- a/packages/nodes-base/credentials/ZammadTokenAuthApi.credentials.ts +++ b/packages/nodes-base/credentials/ZammadTokenAuthApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ZammadTokenAuthApi implements ICredentialType { name = 'zammadTokenAuthApi'; + displayName = 'Zammad Token Auth API'; + documentationUrl = 'zammad'; + properties: INodeProperties[] = [ { displayName: 'Base URL', diff --git a/packages/nodes-base/credentials/ZendeskApi.credentials.ts b/packages/nodes-base/credentials/ZendeskApi.credentials.ts index f4f1e16725..aa1c434845 100644 --- a/packages/nodes-base/credentials/ZendeskApi.credentials.ts +++ b/packages/nodes-base/credentials/ZendeskApi.credentials.ts @@ -8,8 +8,11 @@ import { export class ZendeskApi implements ICredentialType { name = 'zendeskApi'; + displayName = 'Zendesk API'; + documentationUrl = 'zendesk'; + properties: INodeProperties[] = [ { displayName: 'Subdomain', @@ -33,6 +36,7 @@ export class ZendeskApi implements ICredentialType { default: '', }, ]; + async authenticate( credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions, @@ -43,6 +47,7 @@ export class ZendeskApi implements ICredentialType { }; return requestOptions; } + test: ICredentialTestRequest = { request: { baseURL: '=https://{{$credentials.subdomain}}.zendesk.com/api/v2', diff --git a/packages/nodes-base/credentials/ZendeskOAuth2Api.credentials.ts b/packages/nodes-base/credentials/ZendeskOAuth2Api.credentials.ts index 9097d25da0..afcae71809 100644 --- a/packages/nodes-base/credentials/ZendeskOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/ZendeskOAuth2Api.credentials.ts @@ -4,9 +4,13 @@ const scopes = ['read', 'write']; export class ZendeskOAuth2Api implements ICredentialType { name = 'zendeskOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Zendesk OAuth2 API'; + documentationUrl = 'zendesk'; + properties: INodeProperties[] = [ { displayName: 'Subdomain', diff --git a/packages/nodes-base/credentials/ZohoOAuth2Api.credentials.ts b/packages/nodes-base/credentials/ZohoOAuth2Api.credentials.ts index 71ff5d72ff..13565c14c2 100644 --- a/packages/nodes-base/credentials/ZohoOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/ZohoOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ZohoOAuth2Api implements ICredentialType { name = 'zohoOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Zoho OAuth2 API'; + documentationUrl = 'zoho'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/ZoomApi.credentials.ts b/packages/nodes-base/credentials/ZoomApi.credentials.ts index 3934fbb410..5add749fa8 100644 --- a/packages/nodes-base/credentials/ZoomApi.credentials.ts +++ b/packages/nodes-base/credentials/ZoomApi.credentials.ts @@ -7,8 +7,11 @@ import { export class ZoomApi implements ICredentialType { name = 'zoomApi'; + displayName = 'Zoom API'; + documentationUrl = 'zoom'; + properties: INodeProperties[] = [ { displayName: 'JWT Token', @@ -18,6 +21,7 @@ export class ZoomApi implements ICredentialType { default: '', }, ]; + authenticate: IAuthenticateGeneric = { type: 'generic', properties: { @@ -26,6 +30,7 @@ export class ZoomApi implements ICredentialType { }, }, }; + test: ICredentialTestRequest = { request: { baseURL: 'https://api.zoom.us/v2', diff --git a/packages/nodes-base/credentials/ZoomOAuth2Api.credentials.ts b/packages/nodes-base/credentials/ZoomOAuth2Api.credentials.ts index 86eb68b8a9..1997c7e39e 100644 --- a/packages/nodes-base/credentials/ZoomOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/ZoomOAuth2Api.credentials.ts @@ -2,9 +2,13 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ZoomOAuth2Api implements ICredentialType { name = 'zoomOAuth2Api'; + extends = ['oAuth2Api']; + displayName = 'Zoom OAuth2 API'; + documentationUrl = 'zoom'; + properties: INodeProperties[] = [ { displayName: 'Grant Type', diff --git a/packages/nodes-base/credentials/ZulipApi.credentials.ts b/packages/nodes-base/credentials/ZulipApi.credentials.ts index 092b444dc1..1a547237be 100644 --- a/packages/nodes-base/credentials/ZulipApi.credentials.ts +++ b/packages/nodes-base/credentials/ZulipApi.credentials.ts @@ -2,8 +2,11 @@ import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class ZulipApi implements ICredentialType { name = 'zulipApi'; + displayName = 'Zulip API'; + documentationUrl = 'zulip'; + properties: INodeProperties[] = [ { displayName: 'URL', diff --git a/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts b/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts index 21d5d7cac5..aaf8e5096f 100644 --- a/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts +++ b/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts @@ -480,7 +480,7 @@ export class ActionNetwork implements INodeType { if (simplify) { response = operation === 'getAll' - ? response.map((i: Response) => simplifyResponse(i, resource)) + ? response.map((entry: Response) => simplifyResponse(entry, resource)) : simplifyResponse(response, resource); } diff --git a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts index da137a0280..3aab708e60 100644 --- a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts @@ -70,11 +70,11 @@ export async function handleListing( return returnData.slice(0, limit); } - if (responseData._links && responseData._links.next && responseData._links.next.href) { + if (responseData._links?.next?.href) { const queryString = new URLSearchParams(responseData._links.next.href.split('?')[1]); qs.page = queryString.get('page') as string; } - } while (responseData._links && responseData._links.next); + } while (responseData._links?.next); return returnData; } @@ -217,7 +217,7 @@ export const adjustEventPayload = adjustLocation; // ---------------------------------------- async function loadResource(this: ILoadOptionsFunctions, resource: string) { - return await handleListing.call(this, 'GET', `/${resource}`, {}, {}, { returnAll: true }); + return handleListing.call(this, 'GET', `/${resource}`, {}, {}, { returnAll: true }); } export const resourceLoaders = { diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 7cd85d67b3..21de2736aa 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -344,7 +344,7 @@ export class ActiveCampaign implements INodeType { requestMethod = 'POST'; const updateIfExists = this.getNodeParameter('updateIfExists', i) as boolean; - if (updateIfExists === true) { + if (updateIfExists) { endpoint = '/api/3/contact/sync'; } else { endpoint = '/api/3/contacts'; @@ -387,7 +387,7 @@ export class ActiveCampaign implements INodeType { const simple = this.getNodeParameter('simple', i, true) as boolean; const additionalFields = this.getNodeParameter('additionalFields', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -398,7 +398,7 @@ export class ActiveCampaign implements INodeType { delete qs.orderBy; } - if (simple === true) { + if (simple) { dataKey = 'contacts'; } @@ -471,11 +471,11 @@ export class ActiveCampaign implements INodeType { const simple = this.getNodeParameter('simple', i, true) as boolean; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } - if (simple === true) { + if (simple) { dataKey = 'accounts'; } @@ -640,11 +640,11 @@ export class ActiveCampaign implements INodeType { returnAll = this.getNodeParameter('returnAll', i); const simple = this.getNodeParameter('simple', i, true) as boolean; - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } - if (simple === true) { + if (simple) { dataKey = 'lists'; } @@ -696,11 +696,11 @@ export class ActiveCampaign implements INodeType { const simple = this.getNodeParameter('simple', i, true) as boolean; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } - if (simple === true) { + if (simple) { dataKey = 'tags'; } @@ -803,11 +803,11 @@ export class ActiveCampaign implements INodeType { const simple = this.getNodeParameter('simple', i, true) as boolean; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } - if (simple === true) { + if (simple) { dataKey = 'deals'; } @@ -902,11 +902,11 @@ export class ActiveCampaign implements INodeType { const simple = this.getNodeParameter('simple', i, true) as boolean; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } - if (simple === true) { + if (simple) { dataKey = 'connections'; } @@ -932,7 +932,7 @@ export class ActiveCampaign implements INodeType { source: this.getNodeParameter('source', i) as string, email: this.getNodeParameter('email', i) as string, totalPrice: this.getNodeParameter('totalPrice', i) as number, - currency: this.getNodeParameter('currency', i)!.toString().toUpperCase() as string, + currency: this.getNodeParameter('currency', i)!.toString().toUpperCase(), externalCreatedDate: this.getNodeParameter('externalCreatedDate', i) as string, connectionid: this.getNodeParameter('connectionid', i) as number, customerid: this.getNodeParameter('customerid', i) as number, @@ -1002,11 +1002,11 @@ export class ActiveCampaign implements INodeType { const simple = this.getNodeParameter('simple', i, true) as boolean; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } - if (simple === true) { + if (simple) { dataKey = 'ecomOrders'; } @@ -1091,11 +1091,11 @@ export class ActiveCampaign implements INodeType { const simple = this.getNodeParameter('simple', i, true) as boolean; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } - if (simple === true) { + if (simple) { dataKey = 'ecomCustomers'; } @@ -1137,11 +1137,11 @@ export class ActiveCampaign implements INodeType { const simple = this.getNodeParameter('simple', i, true) as boolean; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } - if (simple === true) { + if (simple) { dataKey = 'ecomOrderProducts'; } @@ -1160,7 +1160,7 @@ export class ActiveCampaign implements INodeType { } let responseData; - if (returnAll === true) { + if (returnAll) { responseData = await activeCampaignApiRequestAllItems.call( this, requestMethod, diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts index 75d13187e0..5970d51d19 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts @@ -82,6 +82,7 @@ export class ActiveCampaignTrigger implements INodeType { }, ], }; + methods = { loadOptions: { // Get all the events to display them to user so that he can @@ -108,6 +109,7 @@ export class ActiveCampaignTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts index 88884b1814..e7d5e1799c 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts @@ -102,11 +102,7 @@ export async function activeCampaignApiRequestAllItems( } query.offset = itemsReceived; - } while ( - responseData.meta !== undefined && - responseData.meta.total !== undefined && - responseData.meta.total > itemsReceived - ); + } while (responseData.meta?.total !== undefined && responseData.meta.total > itemsReceived); return returnData; } diff --git a/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts b/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts index 71d090f4cf..746e67ea3b 100644 --- a/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts +++ b/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts @@ -108,6 +108,7 @@ export class AcuitySchedulingTrigger implements INodeType { }, ], }; + // @ts-ignore webhookMethods = { default: { @@ -159,7 +160,7 @@ export class AcuitySchedulingTrigger implements INodeType { const resolveData = this.getNodeParameter('resolveData', false) as boolean; - if (resolveData === false) { + if (!resolveData) { // Return the data as it got received return { workflowData: [this.helpers.returnJsonArray(req.body)], diff --git a/packages/nodes-base/nodes/Affinity/Affinity.node.ts b/packages/nodes-base/nodes/Affinity/Affinity.node.ts index 05a6c8d2ee..6f2b72416b 100644 --- a/packages/nodes-base/nodes/Affinity/Affinity.node.ts +++ b/packages/nodes-base/nodes/Affinity/Affinity.node.ts @@ -164,7 +164,7 @@ export class Affinity implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); responseData = await affinityApiRequest.call(this, 'GET', `/lists`, {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -203,7 +203,7 @@ export class Affinity implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); const listId = this.getNodeParameter('listId', i) as string; - if (returnAll === true) { + if (returnAll) { responseData = await affinityApiRequestAllItems.call( this, 'list_entries', @@ -298,7 +298,7 @@ export class Affinity implements INodeType { if (options.withInteractionDates) { qs.with_interaction_dates = options.withInteractionDates as boolean; } - if (returnAll === true) { + if (returnAll) { responseData = await affinityApiRequestAllItems.call( this, 'persons', @@ -386,7 +386,7 @@ export class Affinity implements INodeType { if (options.withInteractionDates) { qs.with_interaction_dates = options.withInteractionDates as boolean; } - if (returnAll === true) { + if (returnAll) { responseData = await affinityApiRequestAllItems.call( this, 'organizations', diff --git a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts index 620a2fecde..180530d6ce 100644 --- a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts @@ -38,7 +38,7 @@ export async function affinityApiRequest( } options = Object.assign({}, options, option); try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts index 06a7b45dbd..70eafb8bfc 100644 --- a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts +++ b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts @@ -150,7 +150,7 @@ export class AgileCrm implements INodeType { } else if (filterType === 'json') { const filterJsonRules = this.getNodeParameter('filterJson', i) as string; if (validateJSON(filterJsonRules) !== undefined) { - Object.assign(filterJson, jsonParse(filterJsonRules) as IFilter); + Object.assign(filterJson, jsonParse(filterJsonRules)); } else { throw new NodeOperationError(this.getNode(), 'Filter (JSON) must be a valid json', { itemIndex: i, diff --git a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts index 0c6526bce1..393e912385 100644 --- a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts @@ -192,9 +192,10 @@ export function validateJSON(json: string | undefined): any { export function getFilterRules(conditions: ISearchConditions[], matchType: string): IDataObject { const rules = []; + // eslint-disable-next-line @typescript-eslint/no-for-in-array for (const key in conditions) { if (conditions.hasOwnProperty(key)) { - const searchConditions: ISearchConditions = conditions[key] as ISearchConditions; + const searchConditions: ISearchConditions = conditions[key]; const rule: IFilterRules = { LHS: searchConditions.field, CONDITION: searchConditions.condition_type, diff --git a/packages/nodes-base/nodes/Airtable/Airtable.node.ts b/packages/nodes-base/nodes/Airtable/Airtable.node.ts index e06dc28c3b..6430b3fe0c 100644 --- a/packages/nodes-base/nodes/Airtable/Airtable.node.ts +++ b/packages/nodes-base/nodes/Airtable/Airtable.node.ts @@ -530,12 +530,12 @@ export class Airtable implements INodeType { for (let i = 0; i < items.length; i++) { try { addAllFields = this.getNodeParameter('addAllFields', i) as boolean; - options = this.getNodeParameter('options', i, {}) as IDataObject; + options = this.getNodeParameter('options', i, {}); bulkSize = (options.bulkSize as number) || bulkSize; const row: IDataObject = {}; - if (addAllFields === true) { + if (addAllFields) { // Add all the fields the item has row.fields = { ...items[i].json }; delete (row.fields! as any).id; @@ -555,10 +555,10 @@ export class Airtable implements INodeType { if (rows.length === bulkSize || i === items.length - 1) { if (options.typecast === true) { - body['typecast'] = true; + body.typecast = true; } - body['records'] = rows; + body.records = rows; responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); const executionData = this.helpers.constructExecutionMetaData( @@ -581,14 +581,12 @@ export class Airtable implements INodeType { requestMethod = 'DELETE'; const rows: string[] = []; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const bulkSize = (options.bulkSize as number) || 10; for (let i = 0; i < items.length; i++) { try { - let id: string; - - id = this.getNodeParameter('id', i) as string; + const id = this.getNodeParameter('id', i) as string; rows.push(id); @@ -644,7 +642,7 @@ export class Airtable implements INodeType { } } - if (returnAll === true) { + if (returnAll) { responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs); } else { qs.maxRecords = this.getNodeParameter('limit', 0); @@ -731,13 +729,13 @@ export class Airtable implements INodeType { for (let i = 0; i < items.length; i++) { try { updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean; - options = this.getNodeParameter('options', i, {}) as IDataObject; + options = this.getNodeParameter('options', i, {}); bulkSize = (options.bulkSize as number) || bulkSize; const row: IDataObject = {}; row.fields = {} as IDataObject; - if (updateAllFields === true) { + if (updateAllFields) { // Update all the fields the item has row.fields = { ...items[i].json }; // remove id field diff --git a/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts b/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts index 0d48996c28..24ced14dec 100644 --- a/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts +++ b/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts @@ -240,7 +240,7 @@ export class AirtableTrigger implements INodeType { throw new NodeOperationError(this.getNode(), `The Field "${triggerField}" does not exist.`); } - if (downloadAttachments === true) { + if (downloadAttachments) { const downloadFieldNames = (this.getNodeParameter('downloadFieldNames', 0) as string).split( ',', ); diff --git a/packages/nodes-base/nodes/Amqp/Amqp.node.ts b/packages/nodes-base/nodes/Amqp/Amqp.node.ts index 6cf90be1fa..288afa06d5 100644 --- a/packages/nodes-base/nodes/Amqp/Amqp.node.ts +++ b/packages/nodes-base/nodes/Amqp/Amqp.node.ts @@ -102,7 +102,7 @@ export class Amqp implements INodeType { const applicationProperties = this.getNodeParameter('headerParametersJson', 0, {}) as | string | object; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const containerId = options.containerId as string; const containerReconnect = (options.reconnect as boolean) || true; const containerReconnectLimit = (options.reconnectLimit as number) || 50; diff --git a/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts b/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts index da953d331e..5a7f85077f 100644 --- a/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts +++ b/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts @@ -330,11 +330,11 @@ export class ApiTemplateIo implements INodeType { methods = { loadOptions: { async getImageTemplates(this: ILoadOptionsFunctions): Promise { - return await loadResource.call(this, 'image'); + return loadResource.call(this, 'image'); }, async getPdfTemplates(this: ILoadOptionsFunctions): Promise { - return await loadResource.call(this, 'pdf'); + return loadResource.call(this, 'pdf'); }, }, }; @@ -401,16 +401,15 @@ export class ApiTemplateIo implements INodeType { const body = { overrides: [] } as IDataObject; - if (jsonParameters === false) { + if (!jsonParameters) { const overrides = - (((this.getNodeParameter('overridesUi', i) as IDataObject) || {}) - .overrideValues as IDataObject[]) || []; + ((this.getNodeParameter('overridesUi', i) as IDataObject) + ?.overrideValues as IDataObject[]) || []; if (overrides.length !== 0) { const data: IDataObject[] = []; for (const override of overrides) { const properties = - (((override.propertiesUi as IDataObject) || {}) - .propertyValues as IDataObject[]) || []; + ((override.propertiesUi as IDataObject)?.propertyValues as IDataObject[]) || []; data.push( properties.reduce( (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), @@ -435,7 +434,7 @@ export class ApiTemplateIo implements INodeType { responseData = await apiTemplateIoApiRequest.call(this, 'POST', '/create', qs, body); - if (download === true) { + if (download) { const binaryProperty = this.getNodeParameter('binaryProperty', i); const data = await downloadImage.call(this, responseData.download_url); const fileName = responseData.download_url.split('/').pop(); @@ -460,7 +459,7 @@ export class ApiTemplateIo implements INodeType { } } - if (download === true) { + if (download) { return this.prepareOutputData(returnData as unknown as INodeExecutionData[]); } } @@ -492,10 +491,10 @@ export class ApiTemplateIo implements INodeType { let data; - if (jsonParameters === false) { + if (!jsonParameters) { const properties = - (((this.getNodeParameter('propertiesUi', i) as IDataObject) || {}) - .propertyValues as IDataObject[]) || []; + ((this.getNodeParameter('propertiesUi', i) as IDataObject) + ?.propertyValues as IDataObject[]) || []; if (properties.length === 0) { throw new NodeOperationError( this.getNode(), @@ -519,12 +518,12 @@ export class ApiTemplateIo implements INodeType { responseData = await apiTemplateIoApiRequest.call(this, 'POST', '/create', qs, data); - if (download === true) { + if (download) { const binaryProperty = this.getNodeParameter('binaryProperty', i); - const data = await downloadImage.call(this, responseData.download_url); + const imageData = await downloadImage.call(this, responseData.download_url); const fileName = responseData.download_url.split('/').pop(); const binaryData = await this.helpers.prepareBinaryData( - data, + imageData, options.fileName || fileName, ); responseData = { @@ -543,7 +542,7 @@ export class ApiTemplateIo implements INodeType { throw error; } } - if (download === true) { + if (download) { return this.prepareOutputData(returnData as unknown as INodeExecutionData[]); } } diff --git a/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts b/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts index 49f646e776..dc2338e278 100644 --- a/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts @@ -73,7 +73,7 @@ export function validateJSON(json: string | object | undefined): any { return result; } -export function downloadImage(this: IExecuteFunctions, url: string) { +export async function downloadImage(this: IExecuteFunctions, url: string) { return this.helpers.request({ uri: url, method: 'GET', diff --git a/packages/nodes-base/nodes/Asana/Asana.node.ts b/packages/nodes-base/nodes/Asana/Asana.node.ts index b9cbd5e84a..777cc068cd 100644 --- a/packages/nodes-base/nodes/Asana/Asana.node.ts +++ b/packages/nodes-base/nodes/Asana/Asana.node.ts @@ -2009,7 +2009,7 @@ export class Asana implements INodeType { requestMethod = 'DELETE'; - endpoint = ('/tasks/' + this.getNodeParameter('id', i)) as string; + endpoint = '/tasks/' + this.getNodeParameter('id', i); responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); @@ -2021,7 +2021,7 @@ export class Asana implements INodeType { requestMethod = 'GET'; - endpoint = ('/tasks/' + this.getNodeParameter('id', i)) as string; + endpoint = '/tasks/' + this.getNodeParameter('id', i); responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); @@ -2097,7 +2097,7 @@ export class Asana implements INodeType { // ---------------------------------- requestMethod = 'PUT'; - endpoint = ('/tasks/' + this.getNodeParameter('id', i)) as string; + endpoint = '/tasks/' + this.getNodeParameter('id', i); const otherProperties = this.getNodeParameter('otherProperties', i) as IDataObject; Object.assign(body, otherProperties); @@ -2315,7 +2315,7 @@ export class Asana implements INodeType { endpoint = `/projects/${projectId}`; - asanaApiRequest.call(this, requestMethod, endpoint, body, qs); + await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = { success: true }; } diff --git a/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts b/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts index 5775e426d2..3a7427b052 100644 --- a/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts +++ b/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts @@ -159,9 +159,7 @@ export class AsanaTrigger implements INodeType { target: webhookUrl, }; - let responseData; - - responseData = await asanaApiRequest.call(this, 'POST', endpoint, body); + const responseData = await asanaApiRequest.call(this, 'POST', endpoint, body); if (responseData.data === undefined || responseData.data.gid === undefined) { // Required data is missing so was not successful @@ -198,7 +196,7 @@ export class AsanaTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const bodyData = this.getBodyData() as IDataObject; + const bodyData = this.getBodyData(); const headerData = this.getHeaderData() as IDataObject; const req = this.getRequestObject(); diff --git a/packages/nodes-base/nodes/Asana/GenericFunctions.ts b/packages/nodes-base/nodes/Asana/GenericFunctions.ts index 0354128567..c120e64bfb 100644 --- a/packages/nodes-base/nodes/Asana/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Asana/GenericFunctions.ts @@ -53,8 +53,8 @@ export async function asanaApiRequestAllItems( do { responseData = await asanaApiRequest.call(this, method, endpoint, body, query, uri); uri = get(responseData, 'next_page.uri'); - returnData.push.apply(returnData, responseData['data']); - } while (responseData['next_page'] !== null); + returnData.push.apply(returnData, responseData.data); + } while (responseData.next_page !== null); return returnData; } diff --git a/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts b/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts index 58b64f756c..313872639d 100644 --- a/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts +++ b/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts @@ -191,7 +191,7 @@ export class Autopilot implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } responseData = await autopilotApiRequestAllItems.call( @@ -203,7 +203,7 @@ export class Autopilot implements INodeType { qs, ); - if (returnAll === false) { + if (!returnAll) { responseData = responseData.splice(0, qs.limit); } } @@ -246,7 +246,7 @@ export class Autopilot implements INodeType { } } else if (operation === 'add' || operation === 'remove') { responseData = await autopilotApiRequest.call(this, method[operation], endpoint); - responseData['success'] = true; + responseData.success = true; } } @@ -255,7 +255,7 @@ export class Autopilot implements INodeType { const listId = this.getNodeParameter('listId', i) as string; - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } responseData = await autopilotApiRequestAllItems.call( @@ -267,7 +267,7 @@ export class Autopilot implements INodeType { qs, ); - if (returnAll === false) { + if (!returnAll) { responseData = responseData.splice(0, qs.limit); } } @@ -286,14 +286,14 @@ export class Autopilot implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } responseData = await autopilotApiRequest.call(this, 'GET', '/lists'); responseData = responseData.lists; - if (returnAll === false) { + if (!returnAll) { responseData = responseData.splice(0, qs.limit); } } diff --git a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts index 82cc2b6469..ce70145aea 100644 --- a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts @@ -39,7 +39,7 @@ export async function autopilotApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -64,7 +64,7 @@ export async function autopilotApiRequestAllItems( responseData = await autopilotApiRequest.call(this, method, endpoint, body, query); endpoint = `${base}/${responseData.bookmark}`; returnData.push.apply(returnData, responseData[propertyName]); - if (query.limit && returnData.length >= query.limit && returnAll === false) { + if (query.limit && returnData.length >= query.limit && !returnAll) { return returnData; } } while (responseData.bookmark !== undefined); diff --git a/packages/nodes-base/nodes/Aws/AwsLambda.node.ts b/packages/nodes-base/nodes/Aws/AwsLambda.node.ts index 4c6603505c..83850699c5 100644 --- a/packages/nodes-base/nodes/Aws/AwsLambda.node.ts +++ b/packages/nodes-base/nodes/Aws/AwsLambda.node.ts @@ -189,7 +189,7 @@ export class AwsLambda implements INodeType { }, ); - if (responseData !== null && responseData?.errorMessage !== undefined) { + if (responseData?.errorMessage !== undefined) { let _errorMessage = responseData.errorMessage; if (responseData.stackTrace) { diff --git a/packages/nodes-base/nodes/Aws/AwsSns.node.ts b/packages/nodes-base/nodes/Aws/AwsSns.node.ts index d437dcaf84..934c887cbe 100644 --- a/packages/nodes-base/nodes/Aws/AwsSns.node.ts +++ b/packages/nodes-base/nodes/Aws/AwsSns.node.ts @@ -229,7 +229,7 @@ export class AwsSns implements INodeType { const topicName = arnParsed[5]; const awsRegion = arnParsed[3]; - if (filter && topicName.includes(filter) === false) { + if (filter && !topicName.includes(filter)) { continue; } @@ -287,7 +287,7 @@ export class AwsSns implements INodeType { const topic = this.getNodeParameter('topic', i, undefined, { extractValue: true, }) as string; - const params = [('TopicArn=' + topic) as string]; + const params = ['TopicArn=' + topic]; await awsApiRequestSOAP.call( this, @@ -304,9 +304,9 @@ export class AwsSns implements INodeType { }) as string; const params = [ - ('TopicArn=' + topic) as string, - ('Subject=' + this.getNodeParameter('subject', i)) as string, - ('Message=' + this.getNodeParameter('message', i)) as string, + 'TopicArn=' + topic, + 'Subject=' + this.getNodeParameter('subject', i), + 'Message=' + this.getNodeParameter('message', i), ]; const responseData = await awsApiRequestSOAP.call( diff --git a/packages/nodes-base/nodes/Aws/AwsSnsTrigger.node.ts b/packages/nodes-base/nodes/Aws/AwsSnsTrigger.node.ts index 7a4e192034..87b6e8239f 100644 --- a/packages/nodes-base/nodes/Aws/AwsSnsTrigger.node.ts +++ b/packages/nodes-base/nodes/Aws/AwsSnsTrigger.node.ts @@ -139,7 +139,7 @@ export class AwsSnsTrigger implements INodeType { const topicName = arnParsed[5]; const awsRegion = arnParsed[3]; - if (filter && topicName.includes(filter) === false) { + if (filter && !topicName.includes(filter)) { continue; } @@ -153,6 +153,7 @@ export class AwsSnsTrigger implements INodeType { }, }, }; + //@ts-expect-error because of webhook webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/Aws/CertificateManager/AwsCertificateManager.node.ts b/packages/nodes-base/nodes/Aws/CertificateManager/AwsCertificateManager.node.ts index 91de9d6ea7..941051ee2d 100644 --- a/packages/nodes-base/nodes/Aws/CertificateManager/AwsCertificateManager.node.ts +++ b/packages/nodes-base/nodes/Aws/CertificateManager/AwsCertificateManager.node.ts @@ -119,15 +119,15 @@ export class AwsCertificateManager implements INodeType { } if (options.certificateStatuses) { - body.Includes['extendedKeyUsage'] = options.extendedKeyUsage as string[]; + body.Includes.extendedKeyUsage = options.extendedKeyUsage as string[]; } if (options.keyTypes) { - body.Includes['keyTypes'] = options.keyTypes as string[]; + body.Includes.keyTypes = options.keyTypes as string[]; } if (options.keyUsage) { - body.Includes['keyUsage'] = options.keyUsage as string[]; + body.Includes.keyUsage = options.keyUsage as string[]; } if (returnAll) { diff --git a/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts index 6298cdf924..123868abd0 100644 --- a/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts @@ -77,7 +77,7 @@ export async function awsApiRequestAllItems( const data = jsonParse(body as string, { errorMessage: 'Response body is not valid JSON', }); - data['NextToken'] = responseData.NextToken; + data.NextToken = responseData.NextToken; } returnData.push.apply(returnData, get(responseData, propertyName)); } while (responseData.NextToken !== undefined); diff --git a/packages/nodes-base/nodes/Aws/Comprehend/AwsComprehend.node.ts b/packages/nodes-base/nodes/Aws/Comprehend/AwsComprehend.node.ts index 4a2e92a2dd..af8252bc83 100644 --- a/packages/nodes-base/nodes/Aws/Comprehend/AwsComprehend.node.ts +++ b/packages/nodes-base/nodes/Aws/Comprehend/AwsComprehend.node.ts @@ -214,7 +214,7 @@ export class AwsComprehend implements INodeType { { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, ); - if (simple === true) { + if (simple) { responseData = responseData.Languages.reduce( (accumulator: { [key: string]: number }, currentValue: IDataObject) => { accumulator[currentValue.LanguageCode as string] = currentValue.Score as number; diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts b/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts index 372ceb90eb..b1ae1b4060 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts @@ -194,16 +194,16 @@ export class AwsDynamoDB implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); const simple = this.getNodeParameter('simple', 0, false) as boolean; - const items = this.getNodeParameter('keysUi.keyValues', i, []) as [ + const keyValues = this.getNodeParameter('keysUi.keyValues', i, []) as [ { key: string; type: string; value: string }, ]; - for (const item of items) { + for (const item of keyValues) { let value = item.value as NodeParameterValue; // All data has to get send as string even numbers // @ts-ignore value = ![null, undefined].includes(value) ? value?.toString() : ''; - body.Key[item.key as string] = { [item.type as string]: value }; + body.Key[item.key] = { [item.type]: value }; } const expressionAttributeValues = adjustExpressionAttributeValues(eavUi); @@ -231,7 +231,7 @@ export class AwsDynamoDB implements INodeType { if (!Object.keys(responseData).length) { responseData = { success: true }; - } else if (simple === true) { + } else if (simple) { responseData = decodeItem(responseData.Attributes); } } else if (operation === 'get') { @@ -273,9 +273,9 @@ export class AwsDynamoDB implements INodeType { body.ProjectionExpression = additionalFields.projectionExpression as string; } - const items = this.getNodeParameter('keysUi.keyValues', i, []) as IDataObject[]; + const keyValues = this.getNodeParameter('keysUi.keyValues', i, []) as IDataObject[]; - for (const item of items) { + for (const item of keyValues) { let value = item.value as NodeParameterValue; // All data has to get send as string even numbers // @ts-ignore @@ -317,13 +317,13 @@ export class AwsDynamoDB implements INodeType { TableName: this.getNodeParameter('tableName', i) as string, }; - if (scan === true) { + if (scan) { const filterExpression = this.getNodeParameter('filterExpression', i) as string; if (filterExpression) { - body['FilterExpression'] = filterExpression; + body.FilterExpression = filterExpression; } } else { - body['KeyConditionExpression'] = this.getNodeParameter( + body.KeyConditionExpression = this.getNodeParameter( 'keyConditionExpression', i, ) as string; @@ -371,7 +371,7 @@ export class AwsDynamoDB implements INodeType { 'X-Amz-Target': scan ? 'DynamoDB_20120810.Scan' : 'DynamoDB_20120810.Query', }; - if (returnAll === true && select !== 'COUNT') { + if (returnAll && select !== 'COUNT') { responseData = await awsApiRequestAllItems.call( this, 'dynamodb', @@ -387,7 +387,7 @@ export class AwsDynamoDB implements INodeType { responseData = responseData.Items; } } - if (simple === true) { + if (simple) { responseData = responseData.map(simplify); } } diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts index 73b85a3f9d..5197c6968a 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts @@ -36,9 +36,7 @@ export async function awsApiRequest( ); } catch (error) { const errorMessage = - (error.response && error.response.body && error.response.body.message) || - (error.response && error.response.body && error.response.body.Message) || - error.message; + error.response?.body?.message || error.response?.body?.Message || error.message; if (error.statusCode === 403) { if (errorMessage === 'The security token included in the request is invalid.') { throw new Error('The AWS credentials are not valid!'); @@ -80,8 +78,7 @@ export async function awsApiRequestAllItems( export function copyInputItem(item: INodeExecutionData, properties: string[]): IDataObject { // Prepare the data to insert and copy it to be returned - let newItem: IDataObject; - newItem = {}; + const newItem: IDataObject = {}; for (const property of properties) { if (item.json[property] === undefined) { newItem[property] = null; diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts b/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts index eb8829d534..ffc64063a7 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts @@ -96,8 +96,7 @@ export function validateJSON(input: any): object { export function copyInputItem(item: INodeExecutionData, properties: string[]): IDataObject { // Prepare the data to insert and copy it to be returned - let newItem: IDataObject; - newItem = {}; + const newItem: IDataObject = {}; for (const property of properties) { if (item.json[property] === undefined) { newItem[property] = null; diff --git a/packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts b/packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts index 9d317098a4..d89799cab1 100644 --- a/packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts +++ b/packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts @@ -229,11 +229,10 @@ export class AwsElb implements INodeType { const params = ['Version=2015-12-01']; params.push( - ('Certificates.member.1.CertificateArn=' + - this.getNodeParameter('certificateId', i)) as string, + 'Certificates.member.1.CertificateArn=' + this.getNodeParameter('certificateId', i), ); - params.push(('ListenerArn=' + this.getNodeParameter('listenerId', i)) as string); + params.push('ListenerArn=' + this.getNodeParameter('listenerId', i)); responseData = await awsApiRequestSOAP.call( this, @@ -286,11 +285,10 @@ export class AwsElb implements INodeType { const params = ['Version=2015-12-01']; params.push( - ('Certificates.member.1.CertificateArn=' + - this.getNodeParameter('certificateId', i)) as string, + 'Certificates.member.1.CertificateArn=' + this.getNodeParameter('certificateId', i), ); - params.push(('ListenerArn=' + this.getNodeParameter('listenerId', i)) as string); + params.push('ListenerArn=' + this.getNodeParameter('listenerId', i)); responseData = await awsApiRequestSOAP.call( this, @@ -328,15 +326,15 @@ export class AwsElb implements INodeType { params.push(`Type=${type}`); - for (let i = 1; i <= subnets.length; i++) { - params.push(`Subnets.member.${i}=${subnets[i - 1]}`); + for (let index = 1; index <= subnets.length; index++) { + params.push(`Subnets.member.${index}=${subnets[index - 1]}`); } if (additionalFields.securityGroups) { const securityGroups = additionalFields.securityGroups as string[]; - for (let i = 1; i <= securityGroups.length; i++) { - params.push(`SecurityGroups.member.${i}=${securityGroups[i - 1]}`); + for (let index = 1; index <= securityGroups.length; index++) { + params.push(`SecurityGroups.member.${index}=${securityGroups[index - 1]}`); } } @@ -344,10 +342,10 @@ export class AwsElb implements INodeType { const tags = (additionalFields.tagsUi as IDataObject).tagValues as IDataObject[]; if (tags) { - for (let i = 1; i <= tags.length; i++) { - params.push(`Tags.member.${i}.Key=${tags[i - 1].key}`); + for (let index = 1; index <= tags.length; index++) { + params.push(`Tags.member.${index}.Key=${tags[index - 1].key}`); - params.push(`Tags.member.${i}.Value=${tags[i - 1].value}`); + params.push(`Tags.member.${index}.Value=${tags[index - 1].value}`); } } } @@ -367,9 +365,7 @@ export class AwsElb implements INodeType { if (operation === 'delete') { const params = ['Version=2015-12-01']; - params.push( - ('LoadBalancerArn=' + this.getNodeParameter('loadBalancerId', i)) as string, - ); + params.push('LoadBalancerArn=' + this.getNodeParameter('loadBalancerId', i)); responseData = await awsApiRequestSOAP.call( this, @@ -393,8 +389,8 @@ export class AwsElb implements INodeType { if (filters.names) { const names = (filters.names as string).split(','); - for (let i = 1; i <= names.length; i++) { - params.push(`Names.member.${i}=${names[i - 1]}`); + for (let index = 1; index <= names.length; index++) { + params.push(`Names.member.${index}=${names[index - 1]}`); } } @@ -425,9 +421,7 @@ export class AwsElb implements INodeType { if (operation === 'get') { const params = ['Version=2015-12-01']; - params.push( - ('LoadBalancerArns.member.1=' + this.getNodeParameter('loadBalancerId', i)) as string, - ); + params.push('LoadBalancerArns.member.1=' + this.getNodeParameter('loadBalancerId', i)); responseData = await awsApiRequestSOAP.call( this, diff --git a/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts index ac6af43d18..fc5e2f209c 100644 --- a/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts @@ -141,7 +141,7 @@ export async function awsApiRequestSOAPAllItems( ); if (get(responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextMarker`)) { - query['Marker'] = get( + query.Marker = get( responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextMarker`, ); diff --git a/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts b/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts index aa5da0353d..3deca7e3f5 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts @@ -356,7 +356,7 @@ export class AwsRekognition implements INodeType { // property = 'ModerationLabels'; if (additionalFields.minConfidence) { - body['MinConfidence'] = additionalFields.minConfidence as number; + body.MinConfidence = additionalFields.minConfidence as number; } } @@ -370,7 +370,7 @@ export class AwsRekognition implements INodeType { // property = 'FaceDetails'; if (additionalFields.attributes) { - body['Attributes'] = additionalFields.attributes as string; + body.Attributes = additionalFields.attributes as string; } } @@ -378,11 +378,11 @@ export class AwsRekognition implements INodeType { action = 'RekognitionService.DetectLabels'; if (additionalFields.minConfidence) { - body['MinConfidence'] = additionalFields.minConfidence as number; + body.MinConfidence = additionalFields.minConfidence as number; } if (additionalFields.maxLabels) { - body['MaxLabels'] = additionalFields.maxLabels as number; + body.MaxLabels = additionalFields.maxLabels as number; } } @@ -396,13 +396,13 @@ export class AwsRekognition implements INodeType { body.Filters = {}; const box = - (((additionalFields.regionsOfInterestUi as IDataObject) || {}) - .regionsOfInterestValues as IDataObject[]) || []; + ((additionalFields.regionsOfInterestUi as IDataObject) + ?.regionsOfInterestValues as IDataObject[]) || []; if (box.length !== 0) { //@ts-ignore - body.Filters.RegionsOfInterest = box.map((box: IDataObject) => { - return { BoundingBox: keysTPascalCase(box) }; + body.Filters.RegionsOfInterest = box.map((entry: IDataObject) => { + return { BoundingBox: keysTPascalCase(entry) }; }); } diff --git a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts index b5a2c53158..4af8fcc20e 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts @@ -166,7 +166,7 @@ export async function awsApiRequestSOAPAllItems( export function keysTPascalCase(object: IDataObject) { const data: IDataObject = {}; for (const key of Object.keys(object)) { - data[pascalCase(key as string)] = object[key]; + data[pascalCase(key)] = object[key]; } return data; } diff --git a/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts b/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts index 4207d88f81..402ce87387 100644 --- a/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts +++ b/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts @@ -204,7 +204,7 @@ export class AwsS3 implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', 0); if (additionalFields.prefix) { - qs['prefix'] = additionalFields.prefix as string; + qs.prefix = additionalFields.prefix as string; } if (additionalFields.encodingType) { @@ -212,7 +212,7 @@ export class AwsS3 implements INodeType { } if (additionalFields.delmiter) { - qs['delimiter'] = additionalFields.delmiter as string; + qs.delimiter = additionalFields.delmiter as string; } if (additionalFields.fetchOwner) { @@ -392,10 +392,10 @@ export class AwsS3 implements INodeType { if (operation === 'getAll') { const bucketName = this.getNodeParameter('bucketName', i) as string; const returnAll = this.getNodeParameter('returnAll', 0); - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); if (options.folderKey) { - qs['prefix'] = options.folderKey as string; + qs.prefix = options.folderKey as string; } if (options.fetchOwner) { @@ -657,17 +657,17 @@ export class AwsS3 implements INodeType { if (operation === 'getAll') { const bucketName = this.getNodeParameter('bucketName', i) as string; const returnAll = this.getNodeParameter('returnAll', 0); - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); if (options.folderKey) { - qs['prefix'] = options.folderKey as string; + qs.prefix = options.folderKey as string; } if (options.fetchOwner) { qs['fetch-owner'] = options.fetchOwner as string; } - qs['delimiter'] = '/'; + qs.delimiter = '/'; qs['list-type'] = 2; diff --git a/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts b/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts index f48ee46185..d701bb44f4 100644 --- a/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts +++ b/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts @@ -911,7 +911,7 @@ export class AwsSes implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await awsApiRequestSOAPAllItems.call( this, 'ListCustomVerificationEmailTemplatesResponse.ListCustomVerificationEmailTemplatesResult.CustomVerificationEmailTemplates.member', @@ -1153,8 +1153,7 @@ export class AwsSes implements INodeType { } if (templateDataUi) { - const templateDataValues = (templateDataUi as IDataObject) - .templateDataValues as IDataObject[]; + const templateDataValues = templateDataUi.templateDataValues as IDataObject[]; const templateData: IDataObject = {}; if (templateDataValues !== undefined) { for (const templateDataValue of templateDataValues) { @@ -1239,7 +1238,7 @@ export class AwsSes implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await awsApiRequestSOAPAllItems.call( this, 'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member', diff --git a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts index eb44d69819..1beb9d6415 100644 --- a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts @@ -101,7 +101,7 @@ export async function awsApiRequestSOAPAllItems( responseData = await awsApiRequestSOAP.call(this, service, method, path, body, query); if (get(responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`)) { - query['NextToken'] = get( + query.NextToken = get( responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`, ); diff --git a/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts b/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts index 456ca9b1fa..a788388f8a 100644 --- a/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts +++ b/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts @@ -299,7 +299,7 @@ export class AwsSqs implements INodeType { const params = ['Version=2012-11-05', `Action=${pascalCase(operation)}`]; - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); const sendInputData = this.getNodeParameter('sendInputData', i) as boolean; const message = sendInputData diff --git a/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts index a70f858968..2f6cddd71e 100644 --- a/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts @@ -175,7 +175,7 @@ export async function validateCredentials( const response = await this.helpers.request!(options); - return await new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { parseString(response, { explicitArray: false }, (err, data) => { if (err) { return reject(err); diff --git a/packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.node.ts b/packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.node.ts index 942af9059c..dfcd2eeb87 100644 --- a/packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.node.ts +++ b/packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.node.ts @@ -366,7 +366,7 @@ export class AwsTranscribe implements INodeType { const mediaFileUri = this.getNodeParameter('mediaFileUri', i) as string; const detectLang = this.getNodeParameter('detectLanguage', i) as boolean; - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); const body: IDataObject = { TranscriptionJobName: transcriptionJobName, @@ -472,14 +472,14 @@ export class AwsTranscribe implements INodeType { ); responseData = responseData.TranscriptionJob; - if (resolve === true && responseData.TranscriptionJobStatus === 'COMPLETED') { + if (resolve && responseData.TranscriptionJobStatus === 'COMPLETED') { responseData = await this.helpers.request({ method: 'GET', uri: responseData.Transcript.TranscriptFileUri, json: true, }); const simple = this.getNodeParameter('simple', 0) as boolean; - if (simple === true) { + if (simple) { responseData = { transcript: responseData.results.transcripts .map((data: IDataObject) => data.transcript) @@ -496,14 +496,14 @@ export class AwsTranscribe implements INodeType { const body: IDataObject = {}; if (filters.status) { - body['Status'] = filters.status; + body.Status = filters.status; } if (filters.jobNameContains) { - body['JobNameContains'] = filters.jobNameContains; + body.JobNameContains = filters.jobNameContains; } - if (returnAll === true) { + if (returnAll) { responseData = await awsApiRequestRESTAllItems.call( this, 'TranscriptionJobSummaries', @@ -515,7 +515,7 @@ export class AwsTranscribe implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - body['MaxResults'] = limit; + body.MaxResults = limit; responseData = await awsApiRequestREST.call( this, 'transcribe', diff --git a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts index 6ab6aadf66..c6efb94787 100644 --- a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts @@ -107,7 +107,7 @@ export async function awsApiRequestRESTAllItems( responseData = await awsApiRequestREST.call(this, service, method, path, body, query); if (get(responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`)) { - query['NextToken'] = get( + query.NextToken = get( responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`, ); diff --git a/packages/nodes-base/nodes/BambooHr/BambooHr.node.ts b/packages/nodes-base/nodes/BambooHr/BambooHr.node.ts index 3c074ffc9c..6d901cbee7 100644 --- a/packages/nodes-base/nodes/BambooHr/BambooHr.node.ts +++ b/packages/nodes-base/nodes/BambooHr/BambooHr.node.ts @@ -4,8 +4,7 @@ import { INodeType, INodeTypeBaseDescription, INodeTypeDescription } from 'n8n-w import { router } from './v1/actions/router'; import { versionDescription } from './v1/actions/versionDescription'; -import { loadOptions } from './v1/methods'; -import { credentialTest } from './v1/methods'; +import { credentialTest, loadOptions } from './v1/methods'; export class BambooHr implements INodeType { description: INodeTypeDescription; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/shareDescription.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/shareDescription.ts index 76d12900cf..fd735d3908 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/shareDescription.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/shareDescription.ts @@ -293,7 +293,7 @@ export const createEmployeeSharedDescription = (sync = false): INodeProperties[] }, ]; - if (sync === true) { + if (sync) { elements = elements.map((element) => { return Object.assign(element, { displayOptions: { diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/execute.ts index 6651151ca7..e07995e7e0 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/execute.ts @@ -13,7 +13,7 @@ export async function getAll( const endpoint = 'employees/directory'; //limit parameters - const returnAll = this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll = this.getNodeParameter('returnAll', 0, false); const limit = this.getNodeParameter('limit', 0, 0); //response diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/execute.ts index ab1ca39cb5..e66fa0e6c3 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/execute.ts @@ -22,9 +22,9 @@ export async function update( const endpoint = `employees/${id}`; //body parameters - body = this.getNodeParameter('updateFields', index) as IDataObject; + body = this.getNodeParameter('updateFields', index); - const updateFields = this.getNodeParameter('updateFields', index) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', index); const synced = this.getNodeParameter('synced', index) as boolean; if (synced) { diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/sharedDescription.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/sharedDescription.ts index 8344fdbc75..ad9e1b834f 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/sharedDescription.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/sharedDescription.ts @@ -315,7 +315,7 @@ export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] }, ]; - if (sync === true) { + if (sync) { elements = elements.map((element) => { return Object.assign(element, { displayOptions: { 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 270adaead2..82434b7220 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 @@ -16,7 +16,7 @@ export async function getAll( //limit parameters const simplifyOutput: boolean = this.getNodeParameter('simplifyOutput', index) as boolean; - const returnAll: boolean = this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll: boolean = this.getNodeParameter('returnAll', 0, false); const limit: number = this.getNodeParameter('limit', 0, 0); //endpoint diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/execute.ts index 8ea89c1fd0..806396d995 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/execute.ts @@ -19,7 +19,7 @@ export async function update( const endpoint = `employees/${id}/files/${fileId}`; //body parameters - body = this.getNodeParameter('updateFields', index) as IDataObject; + body = this.getNodeParameter('updateFields', index); body.shareWithEmployee ? (body.shareWithEmployee = 'yes') : (body.shareWithEmployee = 'no'); //response diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/upload/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/upload/execute.ts index 2a31f3ff65..4132adbb7c 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/upload/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/upload/execute.ts @@ -1,6 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; -import { IBinaryData, IBinaryKeyData, IDataObject, NodeOperationError } from 'n8n-workflow'; +import { IBinaryKeyData, IDataObject, NodeOperationError } from 'n8n-workflow'; import { apiRequest } from '../../../transport'; @@ -31,7 +31,7 @@ export async function upload(this: IExecuteFunctions, index: number) { const item = items[index].binary as IBinaryKeyData; - const binaryData = item[propertyNameUpload] as IBinaryData; + const binaryData = item[propertyNameUpload]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(index, propertyNameUpload); 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 316ca33501..1d03f3e3a7 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 @@ -14,7 +14,7 @@ export async function getAll( //limit parameters const simplifyOutput: boolean = this.getNodeParameter('simplifyOutput', index) as boolean; - const returnAll: boolean = this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll: boolean = this.getNodeParameter('returnAll', 0, false); const limit: number = this.getNodeParameter('limit', 0, 0); //response diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/execute.ts index 378328fb29..5425de754d 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/execute.ts @@ -1,6 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; -import { IBinaryData, IBinaryKeyData, IDataObject, NodeOperationError } from 'n8n-workflow'; +import { IBinaryKeyData, IDataObject, NodeOperationError } from 'n8n-workflow'; import { apiRequest } from '../../../transport'; @@ -31,7 +31,7 @@ export async function upload(this: IExecuteFunctions, index: number) { const item = items[index].binary as IBinaryKeyData; - const binaryData = item[propertyNameUpload] as IBinaryData; + const binaryData = item[propertyNameUpload]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(index, propertyNameUpload); diff --git a/packages/nodes-base/nodes/BambooHr/v1/methods/credentialTest.ts b/packages/nodes-base/nodes/BambooHr/v1/methods/credentialTest.ts index a4601bb52b..96613b3e1b 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/methods/credentialTest.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/methods/credentialTest.ts @@ -39,11 +39,11 @@ async function validateCredentials( const options: IHttpRequestOptions = { method: 'GET', auth: { - username: apiKey as string, + username: apiKey, password: 'x', }, url: `https://api.bamboohr.com/api/gateway.php/${subdomain}/v1/employees/directory`, }; - return await this.helpers.request(options); + return this.helpers.request(options); } diff --git a/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts b/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts index 30508db81a..7828a2dfc5 100644 --- a/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts +++ b/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts @@ -129,7 +129,7 @@ export class Bannerbear implements INodeType { body.metadata = additionalFields.metadata as string; } if (modifications) { - body.modifications = keysToSnakeCase(modifications) as IDataObject[]; + body.modifications = keysToSnakeCase(modifications); // delete all fields set to empty for (const modification of body.modifications as IDataObject[]) { for (const key of Object.keys(modification)) { @@ -143,7 +143,7 @@ export class Bannerbear implements INodeType { if (additionalFields.waitForImage && responseData.status !== 'completed') { let maxTries = (additionalFields.waitForImageMaxTries as number) || 3; - const promise = (uid: string) => { + const promise = async (uid: string) => { let data: IDataObject = {}; return new Promise((resolve, reject) => { const timeout = setInterval(async () => { diff --git a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts index 5c870b33bb..915bf5ab79 100644 --- a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts @@ -37,7 +37,7 @@ export async function bannerbearApiRequest( } options.headers = Object.assign({}, options.headers, headers); try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Baserow/Baserow.node.ts b/packages/nodes-base/nodes/Baserow/Baserow.node.ts index 786d686bb3..948487dfe9 100644 --- a/packages/nodes-base/nodes/Baserow/Baserow.node.ts +++ b/packages/nodes-base/nodes/Baserow/Baserow.node.ts @@ -119,8 +119,6 @@ export class Baserow implements INodeType { this, 'GET', endpoint, - {}, - {}, jwtToken, )) as LoadedResource[]; return toOptions(databases); @@ -135,8 +133,6 @@ export class Baserow implements INodeType { this, 'GET', endpoint, - {}, - {}, jwtToken, )) as LoadedResource[]; return toOptions(tables); @@ -151,8 +147,6 @@ export class Baserow implements INodeType { this, 'GET', endpoint, - {}, - {}, jwtToken, )) as LoadedResource[]; return toOptions(fields); @@ -189,7 +183,7 @@ export class Baserow implements INodeType { const qs: IDataObject = {}; if (order?.fields) { - qs['order_by'] = order.fields + qs.order_by = order.fields .map(({ field, direction }) => `${direction}${mapper.setField(field)}`) .join(','); } @@ -213,9 +207,9 @@ export class Baserow implements INodeType { this, 'GET', endpoint, + jwtToken, {}, qs, - jwtToken, )) as Row[]; rows.forEach((row) => mapper.idsToNames(row)); @@ -233,7 +227,7 @@ export class Baserow implements INodeType { const rowId = this.getNodeParameter('rowId', i) as string; const endpoint = `/api/database/rows/table/${tableId}/${rowId}/`; - const row = await baserowApiRequest.call(this, 'GET', endpoint, {}, {}, jwtToken); + const row = await baserowApiRequest.call(this, 'GET', endpoint, jwtToken); mapper.idsToNames(row); const executionData = this.helpers.constructExecutionMetaData( @@ -265,21 +259,14 @@ export class Baserow implements INodeType { mapper.namesToIds(body); } } else { - const fields = this.getNodeParameter('fieldsUi.fieldValues', i, []) as FieldsUiValues; - for (const field of fields) { + const fieldsUi = this.getNodeParameter('fieldsUi.fieldValues', i, []) as FieldsUiValues; + for (const field of fieldsUi) { body[`field_${field.fieldId}`] = field.fieldValue; } } const endpoint = `/api/database/rows/table/${tableId}/`; - const createdRow = await baserowApiRequest.call( - this, - 'POST', - endpoint, - body, - {}, - jwtToken, - ); + const createdRow = await baserowApiRequest.call(this, 'POST', endpoint, jwtToken, body); mapper.idsToNames(createdRow); const executionData = this.helpers.constructExecutionMetaData( @@ -313,21 +300,14 @@ export class Baserow implements INodeType { mapper.namesToIds(body); } } else { - const fields = this.getNodeParameter('fieldsUi.fieldValues', i, []) as FieldsUiValues; - for (const field of fields) { + const fieldsUi = this.getNodeParameter('fieldsUi.fieldValues', i, []) as FieldsUiValues; + for (const field of fieldsUi) { body[`field_${field.fieldId}`] = field.fieldValue; } } const endpoint = `/api/database/rows/table/${tableId}/${rowId}/`; - const updatedRow = await baserowApiRequest.call( - this, - 'PATCH', - endpoint, - body, - {}, - jwtToken, - ); + const updatedRow = await baserowApiRequest.call(this, 'PATCH', endpoint, jwtToken, body); mapper.idsToNames(updatedRow); const executionData = this.helpers.constructExecutionMetaData( @@ -345,7 +325,7 @@ export class Baserow implements INodeType { const rowId = this.getNodeParameter('rowId', i) as string; const endpoint = `/api/database/rows/table/${tableId}/${rowId}/`; - await baserowApiRequest.call(this, 'DELETE', endpoint, {}, {}, jwtToken); + await baserowApiRequest.call(this, 'DELETE', endpoint, jwtToken); const executionData = this.helpers.constructExecutionMetaData( [{ json: { success: true } }], diff --git a/packages/nodes-base/nodes/Baserow/GenericFunctions.ts b/packages/nodes-base/nodes/Baserow/GenericFunctions.ts index 0965477cb3..28c02490ff 100644 --- a/packages/nodes-base/nodes/Baserow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Baserow/GenericFunctions.ts @@ -13,9 +13,9 @@ export async function baserowApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, + jwtToken: string, body: IDataObject = {}, qs: IDataObject = {}, - jwtToken: string, ) { const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials; @@ -39,7 +39,7 @@ export async function baserowApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -52,9 +52,9 @@ export async function baserowApiRequestAllItems( this: IExecuteFunctions, method: string, endpoint: string, + jwtToken: string, body: IDataObject, qs: IDataObject = {}, - jwtToken: string, ): Promise { const returnData: IDataObject[] = []; let responseData; @@ -62,11 +62,11 @@ export async function baserowApiRequestAllItems( qs.page = 1; qs.size = 100; - const returnAll = this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll = this.getNodeParameter('returnAll', 0, false); const limit = this.getNodeParameter('limit', 0, 0); do { - responseData = await baserowApiRequest.call(this, method, endpoint, body, qs, jwtToken); + responseData = await baserowApiRequest.call(this, method, endpoint, jwtToken, body, qs); returnData.push(...responseData.results); if (!returnAll && returnData.length > limit) { @@ -114,8 +114,6 @@ export async function getFieldNamesAndIds( this, 'GET', endpoint, - {}, - {}, jwtToken, )) as LoadedResource[]; @@ -133,7 +131,9 @@ export const toOptions = (items: LoadedResource[]) => */ export class TableFieldMapper { nameToIdMapping: Record = {}; + idToNameMapping: Record = {}; + mapIds = true; async getTableFields( @@ -142,7 +142,7 @@ export class TableFieldMapper { jwtToken: string, ): Promise { const endpoint = `/api/database/fields/table/${table}/`; - return await baserowApiRequest.call(this, 'GET', endpoint, {}, {}, jwtToken); + return baserowApiRequest.call(this, 'GET', endpoint, jwtToken); } createMappings(tableFields: LoadedResource[]) { diff --git a/packages/nodes-base/nodes/Beeminder/Beeminder.node.functions.ts b/packages/nodes-base/nodes/Beeminder/Beeminder.node.functions.ts index 65a3a597cc..bcff4801c7 100644 --- a/packages/nodes-base/nodes/Beeminder/Beeminder.node.functions.ts +++ b/packages/nodes-base/nodes/Beeminder/Beeminder.node.functions.ts @@ -12,7 +12,7 @@ export async function createDatapoint( const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`; - return await beeminderApiRequest.call(this, 'POST', endpoint, data); + return beeminderApiRequest.call(this, 'POST', endpoint, data); } export async function getAllDatapoints( @@ -27,7 +27,7 @@ export async function getAllDatapoints( return beeminderApiRequest.call(this, 'GET', endpoint, {}, data); } - return await beeminderApiRequestAllItems.call(this, 'GET', endpoint, {}, data); + return beeminderApiRequestAllItems.call(this, 'GET', endpoint, {}, data); } export async function updateDatapoint( @@ -38,7 +38,7 @@ export async function updateDatapoint( const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`; - return await beeminderApiRequest.call(this, 'PUT', endpoint, data); + return beeminderApiRequest.call(this, 'PUT', endpoint, data); } export async function deleteDatapoint( @@ -49,5 +49,5 @@ export async function deleteDatapoint( const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`; - return await beeminderApiRequest.call(this, 'DELETE', endpoint); + return beeminderApiRequest.call(this, 'DELETE', endpoint); } diff --git a/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts b/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts index 04c05ed685..b0dc5b8beb 100644 --- a/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts +++ b/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts @@ -330,7 +330,7 @@ export class Beeminder implements INodeType { }; Object.assign(data, options); - if (returnAll === false) { + if (!returnAll) { data.count = this.getNodeParameter('limit', 0); } diff --git a/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts b/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts index f93c1f4da5..5bf910c07a 100644 --- a/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts +++ b/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts @@ -247,6 +247,7 @@ export class BitbucketTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { @@ -273,7 +274,6 @@ export class BitbucketTrigger implements INodeType { return false; }, async create(this: IHookFunctions): Promise { - let responseData; let endpoint = ''; const webhookUrl = this.getNodeWebhookUrl('default'); const webhookData = this.getWorkflowStaticData('node'); @@ -294,7 +294,7 @@ export class BitbucketTrigger implements INodeType { active: true, events, }; - responseData = await bitbucketApiRequest.call(this, 'POST', endpoint, body); + const responseData = await bitbucketApiRequest.call(this, 'POST', endpoint, body); webhookData.webhookId = responseData.uuid.replace('{', '').replace('}', ''); return true; }, diff --git a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts index 0cf922ebee..9e973dfd31 100644 --- a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts @@ -71,9 +71,9 @@ export async function bitlyApiRequestAllItems( do { responseData = await bitlyApiRequest.call(this, method, resource, body, query, uri); returnData.push.apply(returnData, responseData[propertyName]); - if (responseData.pagination && responseData.pagination.next) { + if (responseData.pagination?.next) { uri = responseData.pagination.next; } - } while (responseData.pagination !== undefined && responseData.pagination.next !== undefined); + } while (responseData.pagination?.next !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts b/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts index 21f8a5a2e5..7b6a63df46 100644 --- a/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts +++ b/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts @@ -100,11 +100,11 @@ export class Bitwarden implements INodeType { methods = { loadOptions: { async getGroups(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'groups'); + return loadResource.call(this, 'groups'); }, async getCollections(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'collections'); + return loadResource.call(this, 'collections'); }, }, }; diff --git a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts index 7b7313fb62..b01206ad95 100644 --- a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts @@ -43,7 +43,7 @@ export async function bitwardenApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Box/Box.node.ts b/packages/nodes-base/nodes/Box/Box.node.ts index 6f5876057d..359134bb04 100644 --- a/packages/nodes-base/nodes/Box/Box.node.ts +++ b/packages/nodes-base/nodes/Box/Box.node.ts @@ -174,7 +174,7 @@ export class Box implements INodeType { const query = this.getNodeParameter('query', i) as string; const returnAll = this.getNodeParameter('returnAll', i); const additionalFields = this.getNodeParameter('additionalFields', i); - const timezone = this.getTimezone(); + const tz = this.getTimezone(); qs.type = 'file'; qs.query = query; Object.assign(qs, additionalFields); @@ -187,9 +187,9 @@ export class Box implements INodeType { const createdRangeValues = (additionalFields.createdRangeUi as IDataObject) .createdRangeValuesUi as IDataObject; if (createdRangeValues) { - qs.created_at_range = `${moment - .tz(createdRangeValues.from, timezone) - .format()},${moment.tz(createdRangeValues.to, timezone).format()}`; + const from = moment.tz(createdRangeValues.from, tz).format(); + const to = moment.tz(createdRangeValues.to, tz).format(); + qs.created_at_range = `${from},${to}`; } delete qs.createdRangeUi; } @@ -198,9 +198,9 @@ export class Box implements INodeType { const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject) .updatedRangeValuesUi as IDataObject; if (updateRangeValues) { - qs.updated_at_range = `${moment - .tz(updateRangeValues.from, timezone) - .format()},${moment.tz(updateRangeValues.to, timezone).format()}`; + qs.updated_at_range = `${moment.tz(updateRangeValues.from, tz).format()},${moment + .tz(updateRangeValues.to, tz) + .format()}`; } delete qs.updatedRangeUi; } @@ -254,12 +254,12 @@ export class Box implements INodeType { if (accessibleBy === 'user') { const useEmail = this.getNodeParameter('useEmail', i) as boolean; if (useEmail) { - body.accessible_by['login'] = this.getNodeParameter('email', i) as string; + body.accessible_by.login = this.getNodeParameter('email', i) as string; } else { - body.accessible_by['id'] = this.getNodeParameter('userId', i) as string; + body.accessible_by.id = this.getNodeParameter('userId', i) as string; } } else { - body.accessible_by['id'] = this.getNodeParameter('groupId', i) as string; + body.accessible_by.id = this.getNodeParameter('groupId', i) as string; } responseData = await boxApiRequest.call(this, 'POST', `/collaborations`, body, qs); @@ -273,10 +273,10 @@ export class Box implements INodeType { const attributes: IDataObject = {}; if (parentId !== '') { - attributes['parent'] = { id: parentId }; + attributes.parent = { id: parentId }; } else { // if not parent defined save it on the root directory - attributes['parent'] = { id: 0 }; + attributes.parent = { id: 0 }; } if (isBinaryData) { @@ -304,11 +304,11 @@ export class Box implements INodeType { const body: IDataObject = {}; - attributes['name'] = fileName || binaryData.fileName; + attributes.name = fileName || binaryData.fileName; - body['attributes'] = JSON.stringify(attributes); + body.attributes = JSON.stringify(attributes); - body['file'] = { + body.file = { value: binaryDataBuffer, options: { filename: binaryData.fileName, @@ -335,13 +335,13 @@ export class Box implements INodeType { }); } - attributes['name'] = fileName; + attributes.name = fileName; const body: IDataObject = {}; - body['attributes'] = JSON.stringify(attributes); + body.attributes = JSON.stringify(attributes); - body['file'] = { + body.file = { value: Buffer.from(content), options: { filename: fileName, @@ -408,7 +408,7 @@ export class Box implements INodeType { const query = this.getNodeParameter('query', i) as string; const returnAll = this.getNodeParameter('returnAll', i); const additionalFields = this.getNodeParameter('additionalFields', i); - const timezone = this.getTimezone(); + const tz = this.getTimezone(); qs.type = 'folder'; qs.query = query; Object.assign(qs, additionalFields); @@ -421,9 +421,9 @@ export class Box implements INodeType { const createdRangeValues = (additionalFields.createdRangeUi as IDataObject) .createdRangeValuesUi as IDataObject; if (createdRangeValues) { - qs.created_at_range = `${moment - .tz(createdRangeValues.from, timezone) - .format()},${moment.tz(createdRangeValues.to, timezone).format()}`; + qs.created_at_range = `${moment.tz(createdRangeValues.from, tz).format()},${moment + .tz(createdRangeValues.to, tz) + .format()}`; } delete qs.createdRangeUi; } @@ -432,9 +432,9 @@ export class Box implements INodeType { const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject) .updatedRangeValuesUi as IDataObject; if (updateRangeValues) { - qs.updated_at_range = `${moment - .tz(updateRangeValues.from, timezone) - .format()},${moment.tz(updateRangeValues.to, timezone).format()}`; + qs.updated_at_range = `${moment.tz(updateRangeValues.from, tz).format()},${moment + .tz(updateRangeValues.to, tz) + .format()}`; } delete qs.updatedRangeUi; } @@ -488,12 +488,12 @@ export class Box implements INodeType { if (accessibleBy === 'user') { const useEmail = this.getNodeParameter('useEmail', i) as boolean; if (useEmail) { - body.accessible_by['login'] = this.getNodeParameter('email', i) as string; + body.accessible_by.login = this.getNodeParameter('email', i) as string; } else { - body.accessible_by['id'] = this.getNodeParameter('userId', i) as string; + body.accessible_by.id = this.getNodeParameter('userId', i) as string; } } else { - body.accessible_by['id'] = this.getNodeParameter('groupId', i) as string; + body.accessible_by.id = this.getNodeParameter('groupId', i) as string; } responseData = await boxApiRequest.call(this, 'POST', `/collaborations`, body, qs); diff --git a/packages/nodes-base/nodes/Box/GenericFunctions.ts b/packages/nodes-base/nodes/Box/GenericFunctions.ts index e09d5fcbb7..83a333d907 100644 --- a/packages/nodes-base/nodes/Box/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Box/GenericFunctions.ts @@ -63,7 +63,7 @@ export async function boxApiRequestAllItems( query.offset = 0; do { responseData = await boxApiRequest.call(this, method, endpoint, body, query); - query.offset = responseData['offset'] + query.limit; + query.offset = responseData.offset + query.limit; returnData.push.apply(returnData, responseData[propertyName]); } while (responseData[propertyName].length !== 0); diff --git a/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts b/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts index f91694c11e..00fda64f21 100644 --- a/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts +++ b/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts @@ -159,7 +159,7 @@ export class Brandfetch implements INodeType { const response = await brandfetchApiRequest.call(this, 'POST', `/logo`, body); - if (download === true) { + if (download) { const imageTypes = this.getNodeParameter('imageTypes', i) as string[]; const imageFormats = this.getNodeParameter('imageFormats', i) as string[]; @@ -278,7 +278,7 @@ export class Brandfetch implements INodeType { } } - if (operation === 'logo' && this.getNodeParameter('download', 0) === true) { + if (operation === 'logo' && this.getNodeParameter('download', 0)) { // For file downloads the files get attached to the existing items return this.prepareOutputData(items); } else { diff --git a/packages/nodes-base/nodes/Bubble/Bubble.node.ts b/packages/nodes-base/nodes/Bubble/Bubble.node.ts index 7e6cd24eb9..ff7ef38f15 100644 --- a/packages/nodes-base/nodes/Bubble/Bubble.node.ts +++ b/packages/nodes-base/nodes/Bubble/Bubble.node.ts @@ -121,10 +121,10 @@ export class Bubble implements INodeType { const endpoint = `/obj/${typeName}`; - const jsonParameters = this.getNodeParameter('jsonParameters', 0) as boolean; + const jsonParameters = this.getNodeParameter('jsonParameters', 0); const options = this.getNodeParameter('options', i); - if (jsonParameters === false) { + if (!jsonParameters) { if (options.filters) { const { filter } = options.filters as IDataObject; qs.constraints = JSON.stringify(filter); @@ -145,7 +145,7 @@ export class Bubble implements INodeType { Object.assign(qs, sortValue); } - if (returnAll === true) { + if (returnAll) { responseData = await bubbleApiRequestAllItems.call(this, 'GET', endpoint, {}, qs); } else { qs.limit = this.getNodeParameter('limit', 0); diff --git a/packages/nodes-base/nodes/Bubble/GenericFunctions.ts b/packages/nodes-base/nodes/Bubble/GenericFunctions.ts index 4456c1f3f2..8c998a2a6c 100644 --- a/packages/nodes-base/nodes/Bubble/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bubble/GenericFunctions.ts @@ -48,7 +48,7 @@ export async function bubbleApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -71,7 +71,7 @@ export async function bubbleApiRequestAllItems( do { responseData = await bubbleApiRequest.call(this, method, endpoint, body, qs); qs.cursor = responseData.cursor; - returnData.push.apply(returnData, responseData['response']['results']); + returnData.push.apply(returnData, responseData.response.results); } while (responseData.response.remaining !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts b/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts index 0b4b0751de..df8ac3d4d2 100644 --- a/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts +++ b/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts @@ -462,8 +462,8 @@ export class Chargebee implements INodeType { for (let i = 0; i < items.length; i++) { try { _item = items[i]; - const resource = this.getNodeParameter('resource', i) as string; - const operation = this.getNodeParameter('operation', i) as string; + const resource = this.getNodeParameter('resource', i); + const operation = this.getNodeParameter('operation', i); let requestMethod = 'GET'; let endpoint = ''; @@ -596,7 +596,7 @@ export class Chargebee implements INodeType { let responseData; try { - responseData = await this.helpers.request!(options); + responseData = await this.helpers.request(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts b/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts index 09e7772e9d..a347659e1a 100644 --- a/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts +++ b/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts @@ -1,6 +1,6 @@ import { IWebhookFunctions } from 'n8n-core'; -import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; +import { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; export class ChargebeeTrigger implements INodeType { description: INodeTypeDescription = { @@ -222,7 +222,7 @@ export class ChargebeeTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const bodyData = this.getBodyData() as IDataObject; + const bodyData = this.getBodyData(); const req = this.getRequestObject(); const events = this.getNodeParameter('events', []) as string[]; diff --git a/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts b/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts index 665f14d897..07fa7bd950 100644 --- a/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts +++ b/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts @@ -87,7 +87,7 @@ export class CircleCi implements INodeType { const endpoint = `/project/${vcs}/${slug}/pipeline`; - if (returnAll === true) { + if (returnAll) { responseData = await circleciApiRequestAllItems.call( this, 'items', diff --git a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts index ccfd60995d..5c628d7d29 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IDataObject, ILoadOptionsFunctions, INodeExecutionData, @@ -139,23 +138,23 @@ export class CiscoWebex implements INodeType { const markdown = this.getNodeParameter('additionalFields.markdown', i, '') as boolean; const body = {} as IDataObject; if (destination === 'room') { - body['roomId'] = this.getNodeParameter('roomId', i); + body.roomId = this.getNodeParameter('roomId', i); } if (destination === 'person') { const specifyPersonBy = this.getNodeParameter('specifyPersonBy', 0) as string; if (specifyPersonBy === 'id') { - body['toPersonId'] = this.getNodeParameter('toPersonId', i); + body.toPersonId = this.getNodeParameter('toPersonId', i); } else { - body['toPersonEmail'] = this.getNodeParameter('toPersonEmail', i); + body.toPersonEmail = this.getNodeParameter('toPersonEmail', i); } } if (markdown) { - body['markdown'] = markdown; + body.markdown = markdown; } - body['text'] = this.getNodeParameter('text', i); + body.text = this.getNodeParameter('text', i); body.attachments = getAttachemnts( this.getNodeParameter( @@ -177,7 +176,7 @@ export class CiscoWebex implements INodeType { const binaryPropertyName = file.binaryPropertyName as string; - const binaryData = items[i].binary![binaryPropertyName] as IBinaryData; + const binaryData = items[i].binary![binaryPropertyName]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( i, binaryPropertyName, @@ -260,7 +259,7 @@ export class CiscoWebex implements INodeType { Object.assign(qs, filters); } - if (returnAll === true) { + if (returnAll) { responseData = await webexApiRequestAllItems.call( this, 'items', @@ -295,10 +294,10 @@ export class CiscoWebex implements INodeType { roomId: responseData.roomId, } as IDataObject; - if (markdown === true) { - body['markdown'] = this.getNodeParameter('markdownText', i); + if (markdown) { + body.markdown = this.getNodeParameter('markdownText', i); } else { - body['text'] = this.getNodeParameter('text', i); + body.text = this.getNodeParameter('text', i); } responseData = await webexApiRequest.call(this, 'PUT', endpoint, body); @@ -329,7 +328,7 @@ export class CiscoWebex implements INodeType { }; if (body.requireRegistrationInfo) { - body['registration'] = (body.requireRegistrationInfo as string[]).reduce( + body.registration = (body.requireRegistrationInfo as string[]).reduce( (obj, value) => Object.assign(obj, { [`${value}`]: true }), {}, ); @@ -337,7 +336,7 @@ export class CiscoWebex implements INodeType { } if (invitees) { - body['invitees'] = invitees; + body.invitees = invitees; delete body.inviteesUi; } @@ -419,7 +418,7 @@ export class CiscoWebex implements INodeType { .format(); } - if (returnAll === true) { + if (returnAll) { responseData = await webexApiRequestAllItems.call( this, 'items', @@ -459,7 +458,7 @@ export class CiscoWebex implements INodeType { }; if (body.requireRegistrationInfo) { - body['registration'] = (body.requireRegistrationInfo as string[]).reduce( + body.registration = (body.requireRegistrationInfo as string[]).reduce( (obj, value) => Object.assign(obj, { [`${value}`]: true }), {}, ); @@ -467,7 +466,7 @@ export class CiscoWebex implements INodeType { } if (invitees.length) { - body['invitees'] = invitees; + body.invitees = invitees; } if (body.start) { diff --git a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.node.ts b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.node.ts index 90143f02f4..e3cd51cc37 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.node.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.node.ts @@ -534,13 +534,13 @@ export class CiscoWebexTrigger implements INodeType { }; if (filters.ownedBy) { - body['ownedBy'] = filters.ownedBy as string; + body.ownedBy = filters.ownedBy as string; } - body['secret'] = secret; + body.secret = secret; if (filter.length) { - body['filter'] = filter.join('&'); + body.filter = filter.join('&'); } const responseData = await webexApiRequest.call(this, 'POST', endpoint, body); diff --git a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts index 6d7dec6397..891b0d7369 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts @@ -42,7 +42,7 @@ export async function webexApiRequest( delete options.qs; } //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'ciscoWebexOAuth2Api', options, { + return this.helpers.requestOAuth2.call(this, 'ciscoWebexOAuth2Api', options, { tokenType: 'Bearer', }); } catch (error) { @@ -71,13 +71,10 @@ export async function webexApiRequestAllItems( ...options, }); if (responseData.headers.link) { - uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', ''); + uri = responseData.headers.link.split(';')[0].replace('<', '').replace('>', ''); } returnData.push.apply(returnData, responseData.body[propertyName]); - } while ( - responseData.headers['link'] !== undefined && - responseData.headers['link'].includes('rel="next"') - ); + } 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 095c0a9069..a909e7fe57 100644 --- a/packages/nodes-base/nodes/Citrix/ADC/CitrixAdc.node.ts +++ b/packages/nodes-base/nodes/Citrix/ADC/CitrixAdc.node.ts @@ -152,11 +152,7 @@ export class CitrixAdc implements INodeType { 'certificateRequestFileName', i, ) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - {}, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); let body: IDataObject = { reqfile: certificateRequestFileName, diff --git a/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts b/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts index 0e5c6c1e16..e5d040031c 100644 --- a/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts @@ -35,7 +35,7 @@ export async function citrixADCApiRequest( options = Object.assign({}, options, option); try { - return await this.helpers.requestWithAuthentication.call(this, 'citrixAdcApi', options); + return this.helpers.requestWithAuthentication.call(this, 'citrixAdcApi', options); } catch (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 882e6aa632..64b034bbff 100644 --- a/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts +++ b/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts @@ -533,7 +533,7 @@ export class ClickUp implements INodeType { } if (resource === 'comment') { if (operation === 'create') { - const resource = this.getNodeParameter('commentOn', i) as string; + const commentOn = this.getNodeParameter('commentOn', i) as string; const id = this.getNodeParameter('id', i) as string; const commentText = this.getNodeParameter('commentText', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); @@ -549,7 +549,7 @@ export class ClickUp implements INodeType { responseData = await clickupApiRequest.call( this, 'POST', - `/${resource}/${id}/comment`, + `/${commentOn}/${id}/comment`, body, ); } @@ -559,13 +559,13 @@ export class ClickUp implements INodeType { responseData = { success: true }; } if (operation === 'getAll') { - const resource = this.getNodeParameter('commentsOn', i) as string; + const commentsOn = this.getNodeParameter('commentsOn', i) as string; const id = this.getNodeParameter('id', i) as string; qs.limit = this.getNodeParameter('limit', i); responseData = await clickupApiRequest.call( this, 'GET', - `/${resource}/${id}/comment`, + `/${commentsOn}/${id}/comment`, {}, qs, ); @@ -660,9 +660,9 @@ export class ClickUp implements INodeType { body.color = additionalFields.color as string; } if (additionalFields.owners) { - body.owners = ((additionalFields.owners as string).split(',') as string[]).map( - (e: string) => parseInt(e, 10), - ); + body.owners = (additionalFields.owners as string) + .split(',') + .map((e: string) => parseInt(e, 10)); } responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/goal`, body); responseData = responseData.goal; @@ -707,14 +707,14 @@ export class ClickUp implements INodeType { body.color = updateFields.color as string; } if (updateFields.addOwners) { - body.add_owners = ((updateFields.addOwners as string).split(',') as string[]).map( - (e: string) => parseInt(e, 10), - ) as number[]; + body.add_owners = (updateFields.addOwners as string) + .split(',') + .map((e: string) => parseInt(e, 10)); } if (updateFields.removeOwners) { - body.rem_owners = ((updateFields.removeOwners as string).split(',') as string[]).map( - (e: string) => parseInt(e, 10), - ) as number[]; + body.rem_owners = (updateFields.removeOwners as string) + .split(',') + .map((e: string) => parseInt(e, 10)); } responseData = await clickupApiRequest.call(this, 'PUT', `/goal/${goalId}`, body); responseData = responseData.goal; @@ -770,9 +770,9 @@ export class ClickUp implements INodeType { body.list_ids = (additionalFields.listIds as string).split(','); } if (additionalFields.owners) { - body.owners = ((additionalFields.owners as string).split(',') as string[]).map( - (e: string) => parseInt(e, 10), - ); + body.owners = (additionalFields.owners as string) + .split(',') + .map((e: string) => parseInt(e, 10)); } responseData = await clickupApiRequest.call( this, @@ -993,15 +993,15 @@ export class ClickUp implements INodeType { } if (updateFields.addAssignees) { //@ts-ignore - body.assignees.add = ( - (updateFields.addAssignees as string).split(',') as string[] - ).map((e: string) => parseInt(e, 10)); + body.assignees.add = (updateFields.addAssignees as string) + .split(',') + .map((e: string) => parseInt(e, 10)); } if (updateFields.removeAssignees) { //@ts-ignore - body.assignees.rem = ( - (updateFields.removeAssignees as string).split(',') as string[] - ).map((e: string) => parseInt(e, 10)); + body.assignees.rem = (updateFields.removeAssignees as string) + .split(',') + .map((e: string) => parseInt(e, 10)); } if (updateFields.status) { body.status = updateFields.status as string; @@ -1077,7 +1077,7 @@ export class ClickUp implements INodeType { } const listId = this.getNodeParameter('list', i) as string; - if (returnAll === true) { + if (returnAll) { responseData = await clickupApiRequestAllItems.call( this, 'tasks', @@ -1102,7 +1102,7 @@ export class ClickUp implements INodeType { if (operation === 'member') { const taskId = this.getNodeParameter('id', i) as string; const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await clickupApiRequest.call( this, 'GET', @@ -1132,7 +1132,7 @@ export class ClickUp implements INodeType { const body: IDataObject = {}; body.value = value; - if (jsonParse === true) { + if (jsonParse) { body.value = validateJSON(body.value); if (body.value === undefined) { throw new NodeOperationError(this.getNode(), 'Value is invalid JSON!', { @@ -1163,14 +1163,12 @@ export class ClickUp implements INodeType { const taskId = this.getNodeParameter('taskId', i) as string; const name = this.getNodeParameter('tagName', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); - const qs: IDataObject = {}; - Object.assign(qs, additionalFields); responseData = await clickupApiRequest.call( this, 'POST', `/task/${taskId}/tag/${name}`, {}, - qs, + additionalFields, ); responseData = { success: true }; } @@ -1178,14 +1176,12 @@ export class ClickUp implements INodeType { const taskId = this.getNodeParameter('taskId', i) as string; const name = this.getNodeParameter('tagName', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); - const qs: IDataObject = {}; - Object.assign(qs, additionalFields); responseData = await clickupApiRequest.call( this, 'DELETE', `/task/${taskId}/tag/${name}`, {}, - qs, + additionalFields, ); responseData = { success: true }; } @@ -1297,7 +1293,7 @@ export class ClickUp implements INodeType { responseData = responseData.data; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -1308,7 +1304,7 @@ export class ClickUp implements INodeType { let endpoint = `/team/${teamId}/time_entries/current`; - if (running === false) { + if (!running) { const timeEntryId = this.getNodeParameter('timeEntry', i) as string; endpoint = `/team/${teamId}/time_entries/${timeEntryId}`; } @@ -1392,7 +1388,7 @@ export class ClickUp implements INodeType { const body: IDataObject = {}; body.time_entry_ids = timeEntryIds.split(','); if (tagsUi) { - const tags = (tagsUi as IDataObject).tagsValues as IDataObject[]; + const tags = tagsUi.tagsValues as IDataObject[]; if (tags === undefined) { throw new NodeOperationError(this.getNode(), 'At least one tag must be set', { itemIndex: i, @@ -1419,7 +1415,7 @@ export class ClickUp implements INodeType { responseData = responseData.data; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -1476,7 +1472,7 @@ export class ClickUp implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); responseData = await clickupApiRequest.call(this, 'GET', `/space/${spaceId}/tag`); responseData = responseData.tags; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -1545,7 +1541,7 @@ export class ClickUp implements INodeType { if (operation === 'member') { const listId = this.getNodeParameter('id', i) as string; const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await clickupApiRequest.call( this, 'GET', diff --git a/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts b/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts index c08e82eb3b..891ed60c96 100644 --- a/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts +++ b/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts @@ -259,6 +259,7 @@ export class ClickUpTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/Clockify/UserDtos.ts b/packages/nodes-base/nodes/Clockify/UserDtos.ts index 10153db21c..a52245deec 100644 --- a/packages/nodes-base/nodes/Clockify/UserDtos.ts +++ b/packages/nodes-base/nodes/Clockify/UserDtos.ts @@ -1,3 +1,4 @@ +import { IDataObject } from 'n8n-workflow'; import { IMembershipDto } from './CommonDtos'; enum UserStatusEnum { @@ -6,8 +7,6 @@ enum UserStatusEnum { DELETED, } -interface IUserSettingsDto {} - export interface IUserDto { activeWorkspace: string; defaultWorkspace: string; @@ -16,6 +15,6 @@ export interface IUserDto { memberships: IMembershipDto[]; name: string; profilePicture: string; - settings: IUserSettingsDto; + settings: IDataObject; status: UserStatusEnum; } diff --git a/packages/nodes-base/nodes/Cloudflare/Cloudflare.node.ts b/packages/nodes-base/nodes/Cloudflare/Cloudflare.node.ts index bc7857a40d..d1dc1544c8 100644 --- a/packages/nodes-base/nodes/Cloudflare/Cloudflare.node.ts +++ b/packages/nodes-base/nodes/Cloudflare/Cloudflare.node.ts @@ -110,7 +110,7 @@ export class Cloudflare implements INodeType { if (operation === 'getMany') { const zoneId = this.getNodeParameter('zoneId', i) as string; const returnAll = this.getNodeParameter('returnAll', i); - const filters = this.getNodeParameter('filters', i, {}) as IDataObject; + const filters = this.getNodeParameter('filters', i, {}); Object.assign(qs, filters); diff --git a/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts b/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts index 629e737144..bb2f3b180a 100644 --- a/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts @@ -69,7 +69,7 @@ export async function getAllCollectionEntries( body.simple = true; if (options.rawData) { - body.simple = !options.rawData as boolean; + body.simple = !options.rawData; } if (options.language) { diff --git a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts index fd7deba539..e63731eeee 100644 --- a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts @@ -19,10 +19,10 @@ export async function cockpitApiRequest( }, method, qs: { - token: credentials!.accessToken, + token: credentials.accessToken, }, body, - uri: uri || `${credentials!.url}/api${resource}`, + uri: uri || `${credentials.url}/api${resource}`, json: true, }; @@ -58,8 +58,8 @@ export function createDataFromParameters( return unpacked; } - for (const field of uiDataFields!.field as IDataObject[]) { - unpacked[field!.name as string] = field!.value; + for (const field of uiDataFields.field as IDataObject[]) { + unpacked[field.name as string] = field.value; } return unpacked; diff --git a/packages/nodes-base/nodes/Coda/Coda.node.ts b/packages/nodes-base/nodes/Coda/Coda.node.ts index 997b09109b..8e774bebbc 100644 --- a/packages/nodes-base/nodes/Coda/Coda.node.ts +++ b/packages/nodes-base/nodes/Coda/Coda.node.ts @@ -284,7 +284,7 @@ export class Coda implements INodeType { if (options.keyColumns) { // @ts-ignore - (sendData[endpoint]! as IDataObject).keyColumns! = options.keyColumns.split( + (sendData[endpoint]! as IDataObject).keyColumns = options.keyColumns.split( ',', ) as string[]; } @@ -362,7 +362,7 @@ export class Coda implements INodeType { const docId = this.getNodeParameter('docId', 0) as string; const returnAll = this.getNodeParameter('returnAll', 0); const tableId = this.getNodeParameter('tableId', 0) as string; - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); const endpoint = `/docs/${docId}/tables/${tableId}/rows`; if (options.useColumnNames === false) { qs.useColumnNames = options.useColumnNames as boolean; @@ -382,7 +382,7 @@ export class Coda implements INodeType { qs.query = options.query as string; } try { - if (returnAll === true) { + if (returnAll) { responseData = await codaApiRequestAllItems.call( this, 'items', @@ -711,7 +711,7 @@ export class Coda implements INodeType { const docId = this.getNodeParameter('docId', 0) as string; const returnAll = this.getNodeParameter('returnAll', 0); const viewId = this.getNodeParameter('viewId', 0) as string; - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); const endpoint = `/docs/${docId}/tables/${viewId}/rows`; if (options.useColumnNames === false) { qs.useColumnNames = options.useColumnNames as boolean; @@ -728,7 +728,7 @@ export class Coda implements INodeType { qs.query = options.query as string; } try { - if (returnAll === true) { + if (returnAll) { responseData = await codaApiRequestAllItems.call( this, 'items', diff --git a/packages/nodes-base/nodes/Code/ExecutionError.ts b/packages/nodes-base/nodes/Code/ExecutionError.ts index 086abdfbc6..ebb27cd4f4 100644 --- a/packages/nodes-base/nodes/Code/ExecutionError.ts +++ b/packages/nodes-base/nodes/Code/ExecutionError.ts @@ -1,8 +1,12 @@ export class ExecutionError extends Error { description: string | null = null; + itemIndex: number | undefined = undefined; + context: { itemIndex: number } | undefined = undefined; + stack = ''; + lineNumber: number | undefined = undefined; constructor(error: Error & { stack: string }, itemIndex?: number) { diff --git a/packages/nodes-base/nodes/Code/Sandbox.ts b/packages/nodes-base/nodes/Code/Sandbox.ts index 9bfbc67905..3746c092b1 100644 --- a/packages/nodes-base/nodes/Code/Sandbox.ts +++ b/packages/nodes-base/nodes/Code/Sandbox.ts @@ -8,6 +8,7 @@ import type { IExecuteFunctions, IWorkflowDataProxyData, WorkflowExecuteMode } f export class Sandbox extends NodeVM { private jsCode = ''; + private itemIndex: number | undefined = undefined; constructor( diff --git a/packages/nodes-base/nodes/Code/ValidationError.ts b/packages/nodes-base/nodes/Code/ValidationError.ts index 062ca812a6..dd6c660226 100644 --- a/packages/nodes-base/nodes/Code/ValidationError.ts +++ b/packages/nodes-base/nodes/Code/ValidationError.ts @@ -1,7 +1,10 @@ export class ValidationError extends Error { description = ''; + itemIndex: number | undefined = undefined; + context: { itemIndex: number } | undefined = undefined; + lineNumber: number | undefined = undefined; constructor({ diff --git a/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts b/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts index df36b9326a..4d960aef3f 100644 --- a/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts +++ b/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts @@ -197,7 +197,7 @@ export class CoinGecko implements INodeType { responseData = await coinGeckoApiRequest.call(this, 'GET', '/coins/list', {}, qs); - if (returnAll === false) { + if (!returnAll) { limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } diff --git a/packages/nodes-base/nodes/CompareDatasets/CompareDatasets.node.ts b/packages/nodes-base/nodes/CompareDatasets/CompareDatasets.node.ts index ef2f5ae043..b9f277bfc9 100644 --- a/packages/nodes-base/nodes/CompareDatasets/CompareDatasets.node.ts +++ b/packages/nodes-base/nodes/CompareDatasets/CompareDatasets.node.ts @@ -168,18 +168,18 @@ export class CompareDatasets implements INodeType { this.getNodeParameter('mergeByFields.values', 0, []) as IDataObject[], ); - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const input1 = checkInput( this.getInputData(0), - matchFields.map((pair) => pair.field1 as string), + matchFields.map((pair) => pair.field1), (options.disableDotNotation as boolean) || false, 'Input A', ); const input2 = checkInput( this.getInputData(1), - matchFields.map((pair) => pair.field2 as string), + matchFields.map((pair) => pair.field2), (options.disableDotNotation as boolean) || false, 'Input B', ); diff --git a/packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts b/packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts index 9f8a7f8f6f..2324dc156e 100644 --- a/packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts @@ -181,11 +181,11 @@ export function findMatches( fieldsToMatch.forEach((matchCase) => { let valueToCompare; if (disableDotNotation) { - valueToCompare = entry.json[matchCase.field1 as string]; + valueToCompare = entry.json[matchCase.field1]; } else { - valueToCompare = get(entry.json, matchCase.field1 as string); + valueToCompare = get(entry.json, matchCase.field1); } - lookup[matchCase.field2 as string] = valueToCompare; + lookup[matchCase.field2] = valueToCompare; }); for (const fieldValue of Object.values(lookup)) { diff --git a/packages/nodes-base/nodes/Compression/Compression.node.ts b/packages/nodes-base/nodes/Compression/Compression.node.ts index 26dcb8b5c5..d984fed1a2 100644 --- a/packages/nodes-base/nodes/Compression/Compression.node.ts +++ b/packages/nodes-base/nodes/Compression/Compression.node.ts @@ -294,7 +294,7 @@ export class Compression implements INodeType { } else if (outputFormat === 'gzip') { const outputPrefix = this.getNodeParameter('outputPrefix', 0) as string; - const data = (await gzip(binaryDataBuffer)) as Uint8Array; + const data = await gzip(binaryDataBuffer); const fileName = binaryData.fileName?.split('.')[0]; diff --git a/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts b/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts index 2a7e92b981..d6188b0ec8 100644 --- a/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts +++ b/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts @@ -380,9 +380,9 @@ export class ConvertKit implements INodeType { if (resource === 'tag') { if (operation === 'create') { - const names = ((this.getNodeParameter('name', i) as string).split(',') as string[]).map( - (e) => ({ name: e }), - ); + const names = (this.getNodeParameter('name', i) as string) + .split(',') + .map((e) => ({ name: e })); const body: IDataObject = { tag: names, diff --git a/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts b/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts index 8f27cb6beb..a1e392b1c2 100644 --- a/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts +++ b/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts @@ -274,27 +274,27 @@ export class ConvertKitTrigger implements INodeType { if (event === 'subscriber.form_subscribe') { //@ts-ignore - body.event['form_id'] = this.getNodeParameter('formId', 0); + body.event.form_id = this.getNodeParameter('formId', 0); } if (event === 'subscriber.course_subscribe' || event === 'subscriber.course_complete') { //@ts-ignore - body.event['sequence_id'] = this.getNodeParameter('courseId', 0); + body.event.sequence_id = this.getNodeParameter('courseId', 0); } if (event === 'subscriber.link_click') { //@ts-ignore - body.event['initiator_value'] = this.getNodeParameter('link', 0); + body.event.initiator_value = this.getNodeParameter('link', 0); } if (event === 'subscriber.product_purchase') { //@ts-ignore - body.event['product_id'] = this.getNodeParameter('productId', 0); + body.event.product_id = this.getNodeParameter('productId', 0); } if (event === 'subscriber.tag_add' || event === 'subscriber.tag_remove') { //@ts-ignore - body.event['tag_id'] = this.getNodeParameter('tagId', 0); + body.event.tag_id = this.getNodeParameter('tagId', 0); } const webhook = await convertKitApiRequest.call(this, 'POST', endpoint, body); diff --git a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts index 7e0b5544f1..81e14f681f 100644 --- a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts @@ -35,7 +35,7 @@ export async function convertKitApiRequest( // it's a webhook so include the api secret on the body if ((options.uri as string).includes('/automations/hooks')) { - options.body['api_secret'] = credentials.apiSecret; + options.body.api_secret = credentials.apiSecret; } else { qs.api_secret = credentials.apiSecret; } @@ -45,7 +45,7 @@ export async function convertKitApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts b/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts index f1127fed7c..779c1465f9 100644 --- a/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts +++ b/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts @@ -94,6 +94,7 @@ export class CopperTrigger implements INodeType { }, ], }; + // @ts-ignore webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/Copper/GenericFunctions.ts b/packages/nodes-base/nodes/Copper/GenericFunctions.ts index e5b86ea99d..6e95ff921c 100644 --- a/packages/nodes-base/nodes/Copper/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Copper/GenericFunctions.ts @@ -156,18 +156,24 @@ export async function handleListing( body: IDataObject = {}, uri = '', ) { - let responseData; - const returnAll = this.getNodeParameter('returnAll', 0); const option = { resolveWithFullResponse: true }; if (returnAll) { - return await copperApiRequestAllItems.call(this, method, endpoint, body, qs, uri, option); + return copperApiRequestAllItems.call(this, method, endpoint, body, qs, uri, option); } const limit = this.getNodeParameter('limit', 0); - responseData = await copperApiRequestAllItems.call(this, method, endpoint, body, qs, uri, option); + const responseData = await copperApiRequestAllItems.call( + this, + method, + endpoint, + body, + qs, + uri, + option, + ); return responseData.slice(0, limit); } diff --git a/packages/nodes-base/nodes/Cortex/Cortex.node.ts b/packages/nodes-base/nodes/Cortex/Cortex.node.ts index d162dc44d5..046232cc68 100644 --- a/packages/nodes-base/nodes/Cortex/Cortex.node.ts +++ b/packages/nodes-base/nodes/Cortex/Cortex.node.ts @@ -5,7 +5,6 @@ import { cortexApiRequest, getEntityLabel, prepareParameters, splitTags } from ' import { analyzerFields, analyzersOperations } from './AnalyzerDescriptions'; import { - IBinaryData, IDataObject, ILoadOptionsFunctions, INodeExecutionData, @@ -321,7 +320,7 @@ export class Cortex implements INodeType { const artifacts = (body.data as IDataObject).artifacts as IDataObject; if (artifacts) { - const artifactValues = (artifacts as IDataObject).artifactValues as IDataObject[]; + const artifactValues = artifacts.artifactValues as IDataObject[]; if (artifactValues) { const artifactData = []; @@ -331,7 +330,7 @@ export class Cortex implements INodeType { element.message = artifactvalue.message as string; - element.tags = splitTags(artifactvalue.tags as string) as string[]; + element.tags = splitTags(artifactvalue.tags as string); element.dataType = artifactvalue.dataType as string; @@ -358,7 +357,7 @@ export class Cortex implements INodeType { ); } - const binaryData = item.binary[binaryPropertyName] as IBinaryData; + const binaryData = item.binary[binaryPropertyName]; element.data = `${binaryData.fileName};${binaryData.mimeType};${binaryData.data}`; } diff --git a/packages/nodes-base/nodes/CrateDb/CrateDb.node.ts b/packages/nodes-base/nodes/CrateDb/CrateDb.node.ts index bc874b7fed..87bdf2f36e 100644 --- a/packages/nodes-base/nodes/CrateDb/CrateDb.node.ts +++ b/packages/nodes-base/nodes/CrateDb/CrateDb.node.ts @@ -1,6 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IDataObject, INodeExecutionData, INodeType, INodeTypeDescription, @@ -374,10 +373,10 @@ export class CrateDb implements INodeType { ); } const _updateItems = await db.multi(pgp.helpers.concat(queries)); - returnItems = this.helpers.returnJsonArray(getItemsCopy(items, columns) as IDataObject[]); + returnItems = this.helpers.returnJsonArray(getItemsCopy(items, columns)); } } else { - await pgp.end(); + pgp.end(); throw new NodeOperationError( this.getNode(), `The operation "${operation}" is not supported!`, @@ -385,7 +384,7 @@ export class CrateDb implements INodeType { } // Close the connection - await pgp.end(); + pgp.end(); return this.prepareOutputData(returnItems); } diff --git a/packages/nodes-base/nodes/Crypto/Crypto.node.ts b/packages/nodes-base/nodes/Crypto/Crypto.node.ts index b254f05c63..edb01bfd0c 100644 --- a/packages/nodes-base/nodes/Crypto/Crypto.node.ts +++ b/packages/nodes-base/nodes/Crypto/Crypto.node.ts @@ -475,7 +475,7 @@ export class Crypto implements INodeType { const encoding = this.getNodeParameter('encoding', i) as BinaryToTextEncoding; const privateKey = this.getNodeParameter('privateKey', i) as string; const sign = createSign(algorithm); - sign.write(value as string); + sign.write(value); sign.end(); newValue = sign.sign(privateKey, encoding); } diff --git a/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts b/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts index 4a43f03812..3ddac232f0 100644 --- a/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts +++ b/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts @@ -213,6 +213,7 @@ export class CustomerIoTrigger implements INodeType { }, ], }; + // @ts-ignore (because of request) webhookMethods = { default: { @@ -247,7 +248,6 @@ export class CustomerIoTrigger implements INodeType { return false; }, async create(this: IHookFunctions): Promise { - let webhook; const webhookUrl = this.getNodeWebhookUrl('default'); const events = this.getNodeParameter('events', []) as string[]; @@ -288,7 +288,7 @@ export class CustomerIoTrigger implements INodeType { events: data, }; - webhook = await customerIoApiRequest.call(this, 'POST', endpoint, body, 'beta'); + const webhook = await customerIoApiRequest.call(this, 'POST', endpoint, body, 'beta'); const webhookData = this.getWorkflowStaticData('node'); webhookData.webhookId = webhook.id as string; diff --git a/packages/nodes-base/nodes/DateTime/DateTime.node.ts b/packages/nodes-base/nodes/DateTime/DateTime.node.ts index b314846b5b..ba7b56237b 100644 --- a/packages/nodes-base/nodes/DateTime/DateTime.node.ts +++ b/packages/nodes-base/nodes/DateTime/DateTime.node.ts @@ -402,18 +402,18 @@ export class DateTime implements INodeType { const fromTimezone = options.fromTimezone || workflowTimezone; if (options.fromFormat) { newDate = moment.tz( - currentDate as string, + currentDate, options.fromFormat as string, fromTimezone as string, ); } else { - newDate = moment.tz(currentDate as string, fromTimezone as string); + newDate = moment.tz(currentDate, fromTimezone as string); } } else { if (options.fromFormat) { - newDate = moment(currentDate as string, options.fromFormat as string); + newDate = moment(currentDate, options.fromFormat as string); } else { - newDate = moment(currentDate as string); + newDate = moment(currentDate); } } } diff --git a/packages/nodes-base/nodes/DeepL/DeepL.node.ts b/packages/nodes-base/nodes/DeepL/DeepL.node.ts index a05014639b..f7c6eaf099 100644 --- a/packages/nodes-base/nodes/DeepL/DeepL.node.ts +++ b/packages/nodes-base/nodes/DeepL/DeepL.node.ts @@ -112,8 +112,8 @@ export class DeepL implements INodeType { for (let i = 0; i < length; i++) { try { - const resource = this.getNodeParameter('resource', i) as string; - const operation = this.getNodeParameter('operation', i) as string; + const resource = this.getNodeParameter('resource', i); + const operation = this.getNodeParameter('operation', i); const additionalFields = this.getNodeParameter('additionalFields', i); if (resource === 'language') { if (operation === 'translate') { diff --git a/packages/nodes-base/nodes/Demio/Demio.node.ts b/packages/nodes-base/nodes/Demio/Demio.node.ts index 2c1cab8866..7c2b9d8f6b 100644 --- a/packages/nodes-base/nodes/Demio/Demio.node.ts +++ b/packages/nodes-base/nodes/Demio/Demio.node.ts @@ -138,7 +138,7 @@ export class Demio implements INodeType { responseData = await demioApiRequest.call(this, 'GET', `/events`, {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -159,8 +159,8 @@ export class Demio implements INodeType { if (additionalFields.customFieldsUi) { const customFields = - (((additionalFields.customFieldsUi as IDataObject) || {}) - .customFieldsValues as IDataObject[]) || []; + ((additionalFields.customFieldsUi as IDataObject) + ?.customFieldsValues as IDataObject[]) || []; const data = customFields.reduce( (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.value }), {}, diff --git a/packages/nodes-base/nodes/Discord/Discord.node.ts b/packages/nodes-base/nodes/Discord/Discord.node.ts index d3c4e88c6e..00a6a9e3a9 100644 --- a/packages/nodes-base/nodes/Discord/Discord.node.ts +++ b/packages/nodes-base/nodes/Discord/Discord.node.ts @@ -127,11 +127,11 @@ export class Discord implements INodeType { if (!webhookUri) throw new NodeOperationError(this.getNode(), 'Webhook uri is required.'); const items = this.getInputData(); - const length = items.length as number; + const length = items.length; for (let i = 0; i < length; i++) { const body: DiscordWebhook = {}; - const webhookUri = this.getNodeParameter('webhookUri', i) as string; + const iterationWebhookUri = this.getNodeParameter('webhookUri', i) as string; body.content = this.getNodeParameter('text', i) as string; const options = this.getNodeParameter('options', i); @@ -215,7 +215,7 @@ export class Discord implements INodeType { resolveWithFullResponse: true, method: 'POST', body, - uri: webhookUri, + uri: iterationWebhookUri, headers: { 'content-type': 'application/json; charset=utf-8', }, @@ -226,7 +226,7 @@ export class Discord implements INodeType { resolveWithFullResponse: true, method: 'POST', body, - uri: webhookUri, + uri: iterationWebhookUri, headers: { 'content-type': 'multipart/form-data; charset=utf-8', }, diff --git a/packages/nodes-base/nodes/Discourse/Discourse.node.ts b/packages/nodes-base/nodes/Discourse/Discourse.node.ts index 3d9041b8a5..b205f9c718 100644 --- a/packages/nodes-base/nodes/Discourse/Discourse.node.ts +++ b/packages/nodes-base/nodes/Discourse/Discourse.node.ts @@ -143,7 +143,7 @@ export class Discourse implements INodeType { responseData = responseData.category_list.categories; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -203,7 +203,7 @@ export class Discourse implements INodeType { responseData = responseData.groups; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -273,7 +273,7 @@ export class Discourse implements INodeType { } responseData.push(lastPost); - if (returnAll === false) { + if (!returnAll) { responseData = responseData.splice(0, limit); } } @@ -381,7 +381,7 @@ export class Discourse implements INodeType { qs, ); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } diff --git a/packages/nodes-base/nodes/Drift/GenericFunctions.ts b/packages/nodes-base/nodes/Drift/GenericFunctions.ts index 0caf34c7e6..6d9fc97599 100644 --- a/packages/nodes-base/nodes/Drift/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Drift/GenericFunctions.ts @@ -37,11 +37,11 @@ export async function driftApiRequest( if (authenticationMethod === 'accessToken') { const credentials = await this.getCredentials('driftApi'); - options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; + options.headers!.Authorization = `Bearer ${credentials.accessToken}`; - return await this.helpers.request!(options); + return this.helpers.request!(options); } else { - return await this.helpers.requestOAuth2!.call(this, 'driftOAuth2Api', options); + return this.helpers.requestOAuth2!.call(this, 'driftOAuth2Api', options); } } catch (error) { throw new NodeApiError(this.getNode(), error); diff --git a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts index 99e9ab7d70..4791b68502 100644 --- a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts +++ b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts @@ -759,7 +759,7 @@ export class Dropbox implements INodeType { options = { json: false }; - if (this.getNodeParameter('binaryData', i) === true) { + if (this.getNodeParameter('binaryData', i)) { // Is binary file to upload const item = items[i]; @@ -814,7 +814,7 @@ export class Dropbox implements INodeType { limit: 1000, }; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); body.limit = limit; } @@ -851,7 +851,7 @@ export class Dropbox implements INodeType { Object.assign(body.options!, filters); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); Object.assign(body.options!, { max_results: limit }); } @@ -909,7 +909,7 @@ export class Dropbox implements INodeType { let responseData; - if (returnAll === true) { + if (returnAll) { responseData = await dropboxpiRequestAllItems.call( this, property, @@ -977,7 +977,7 @@ export class Dropbox implements INodeType { is_downloadable: 'isDownloadable', }; - if (returnAll === false) { + if (!returnAll) { responseData = responseData.entries; } @@ -999,10 +999,10 @@ export class Dropbox implements INodeType { } } else if (resource === 'search' && operation === 'query') { let data = responseData; - if (returnAll === true) { - data = simple === true ? simplify(responseData) : responseData; + if (returnAll) { + data = simple ? simplify(responseData) : responseData; } else { - data = simple === true ? simplify(responseData[property]) : responseData[property]; + data = simple ? simplify(responseData[property]) : responseData[property]; } const executionData = this.helpers.constructExecutionMetaData( diff --git a/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts b/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts index d8997e541e..1385cb9aeb 100644 --- a/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts @@ -78,7 +78,7 @@ export async function dropboxpiRequestAllItems( return returnData; } -export function getRootDirectory(this: IHookFunctions | IExecuteFunctions) { +export async function getRootDirectory(this: IHookFunctions | IExecuteFunctions) { return dropboxApiRequest.call( this, 'POST', diff --git a/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts b/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts index 181a405915..2b112ed988 100644 --- a/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts +++ b/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts @@ -239,6 +239,7 @@ export class Dropcontact implements INodeType { }, ], }; + async execute(this: IExecuteFunctions): Promise { const entryData = this.getInputData(); const resource = this.getNodeParameter('resource', 0); @@ -249,7 +250,7 @@ export class Dropcontact implements INodeType { if (resource === 'contact') { if (operation === 'enrich') { - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); const data = []; const simplify = this.getNodeParameter('simplify', 0) as boolean; @@ -285,10 +286,10 @@ export class Dropcontact implements INodeType { } } - if (simplify === false) { + if (!simplify) { const waitTime = this.getNodeParameter('options.waitTime', 0, 45) as number; - const delay = (ms: any) => new Promise((res) => setTimeout(res, ms * 1000)); + const delay = async (ms: any) => new Promise((res) => setTimeout(res, ms * 1000)); await delay(waitTime); responseData = await dropcontactApiRequest.call( this, diff --git a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts index 0f269b8227..b43e29fbfb 100644 --- a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function erpNextApiRequest( qs: query, uri: uri || `${baseUrl}${resource}`, json: true, - rejectUnauthorized: !credentials.allowUnauthorizedCerts as boolean, + rejectUnauthorized: !credentials.allowUnauthorizedCerts, }; options = Object.assign({}, options, option); @@ -39,7 +39,7 @@ export async function erpNextApiRequest( delete options.qs; } try { - return await this.helpers.requestWithAuthentication.call(this, 'erpNextApi', options); + return this.helpers.requestWithAuthentication.call(this, 'erpNextApi', options); } catch (error) { if (error.statusCode === 403) { throw new NodeApiError(this.getNode(), { message: 'DocType unavailable.' }); @@ -65,13 +65,13 @@ export async function erpNextApiRequestAllItems( const returnData: any[] = []; let responseData; - query!.limit_start = 0; - query!.limit_page_length = 1000; + query.limit_start = 0; + query.limit_page_length = 1000; do { responseData = await erpNextApiRequest.call(this, method, resource, body, query); returnData.push.apply(returnData, responseData[propertyName]); - query!.limit_start += query!.limit_page_length - 1; + query.limit_start += query.limit_page_length - 1; } while (responseData.data && responseData.data.length > 0); return returnData; diff --git a/packages/nodes-base/nodes/EditImage/EditImage.node.ts b/packages/nodes-base/nodes/EditImage/EditImage.node.ts index 06c1161915..1dcaaf8ebe 100644 --- a/packages/nodes-base/nodes/EditImage/EditImage.node.ts +++ b/packages/nodes-base/nodes/EditImage/EditImage.node.ts @@ -777,20 +777,14 @@ export class EditImage implements INodeType { }, ...nodeOperations, ].sort((a, b) => { - if ( - (a as INodePropertyOptions).name.toLowerCase() < - (b as INodePropertyOptions).name.toLowerCase() - ) { + if (a.name.toLowerCase() < b.name.toLowerCase()) { return -1; } - if ( - (a as INodePropertyOptions).name.toLowerCase() > - (b as INodePropertyOptions).name.toLowerCase() - ) { + if (a.name.toLowerCase() > b.name.toLowerCase()) { return 1; } return 0; - }) as INodePropertyOptions[], + }), default: 'border', }, { @@ -948,15 +942,15 @@ export class EditImage implements INodeType { const files = await getSystemFonts(); const returnData: INodePropertyOptions[] = []; - files.forEach((file: string) => { - const pathParts = pathParse(file); + files.forEach((entry: string) => { + const pathParts = pathParse(entry); if (!pathParts.ext) { return; } returnData.push({ name: pathParts.name, - value: file, + value: entry, }); }); @@ -991,10 +985,10 @@ export class EditImage implements INodeType { try { item = items[itemIndex]; - const operation = this.getNodeParameter('operation', itemIndex) as string; + const operation = this.getNodeParameter('operation', itemIndex); const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); const cleanupFunctions: Array<() => void> = []; @@ -1056,7 +1050,7 @@ export class EditImage implements INodeType { }); } - if (item.binary[dataPropertyName as string] === undefined) { + if (item.binary[dataPropertyName] === undefined) { throw new NodeOperationError( this.getNode(), `Item does not contain any binary data with the name "${dataPropertyName}".`, @@ -1083,12 +1077,12 @@ export class EditImage implements INodeType { if (operation === 'information') { // Just return the information const imageData = await new Promise((resolve, reject) => { - gmInstance = gmInstance.identify((error, imageData) => { + gmInstance = gmInstance.identify((error, data) => { if (error) { reject(error); return; } - resolve(imageData as unknown as IDataObject); + resolve(data as unknown as IDataObject); }); }); @@ -1269,15 +1263,13 @@ export class EditImage implements INodeType { // but the incoming data does not get changed. Object.assign(newItem.binary, item.binary); // Make a deep copy of the binary data we change - if (newItem.binary![dataPropertyName as string]) { - newItem.binary![dataPropertyName as string] = deepCopy( - newItem.binary![dataPropertyName as string], - ); + if (newItem.binary[dataPropertyName]) { + newItem.binary[dataPropertyName] = deepCopy(newItem.binary[dataPropertyName]); } } - if (newItem.binary![dataPropertyName as string] === undefined) { - newItem.binary![dataPropertyName as string] = { + if (newItem.binary![dataPropertyName] === undefined) { + newItem.binary![dataPropertyName] = { data: '', mimeType: '', }; @@ -1289,31 +1281,31 @@ export class EditImage implements INodeType { if (options.format !== undefined) { gmInstance = gmInstance!.setFormat(options.format as string); - newItem.binary![dataPropertyName as string].fileExtension = options.format as string; - newItem.binary![dataPropertyName as string].mimeType = `image/${options.format}`; - const fileName = newItem.binary![dataPropertyName as string].fileName; - if (fileName && fileName.includes('.')) { - newItem.binary![dataPropertyName as string].fileName = + newItem.binary![dataPropertyName].fileExtension = options.format as string; + newItem.binary![dataPropertyName].mimeType = `image/${options.format}`; + const fileName = newItem.binary![dataPropertyName].fileName; + if (fileName?.includes('.')) { + newItem.binary![dataPropertyName].fileName = fileName.split('.').slice(0, -1).join('.') + '.' + options.format; } } if (options.fileName !== undefined) { - newItem.binary![dataPropertyName as string].fileName = options.fileName as string; + newItem.binary![dataPropertyName].fileName = options.fileName as string; } returnData.push( await new Promise((resolve, reject) => { gmInstance.toBuffer(async (error: Error | null, buffer: Buffer) => { - cleanupFunctions.forEach(async (cleanup) => await cleanup()); + cleanupFunctions.forEach(async (cleanup) => cleanup()); if (error) { return reject(error); } const binaryData = await this.helpers.prepareBinaryData(Buffer.from(buffer)); - newItem.binary![dataPropertyName as string] = { - ...newItem.binary![dataPropertyName as string], + newItem.binary![dataPropertyName] = { + ...newItem.binary![dataPropertyName], ...binaryData, }; diff --git a/packages/nodes-base/nodes/Egoi/Egoi.node.ts b/packages/nodes-base/nodes/Egoi/Egoi.node.ts index 659c998272..c4e3214817 100644 --- a/packages/nodes-base/nodes/Egoi/Egoi.node.ts +++ b/packages/nodes-base/nodes/Egoi/Egoi.node.ts @@ -631,7 +631,7 @@ export class Egoi implements INodeType { responseData = responseData.items; } - if (simple === true) { + if (simple) { const data = (await simplify.call(this, [responseData], listId))[0]; responseData = { @@ -674,7 +674,7 @@ export class Egoi implements INodeType { responseData = responseData.items; } - if (simple === true) { + if (simple) { responseData = await simplify.call(this, responseData, listId); } } @@ -735,7 +735,7 @@ export class Egoi implements INodeType { } } } catch (error) { - if (this.continueOnFail() !== true) { + if (!this.continueOnFail()) { throw error; } else { // Return the actual reason as error diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts index 88bb73fb04..d78c9e2fb0 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts @@ -454,7 +454,7 @@ export class ElasticSecurity implements INodeType { const endpoint = `/cases/${caseId}/comments`; responseData = await elasticSecurityApiRequest.call(this, 'POST', endpoint, body); - if (simple === true) { + if (simple) { const { comments } = responseData; responseData = comments[comments.length - 1]; } @@ -516,7 +516,7 @@ export class ElasticSecurity implements INodeType { const patchEndpoint = `/cases/${caseId}/comments`; responseData = await elasticSecurityApiRequest.call(this, 'PATCH', patchEndpoint, body); - if (simple === true) { + if (simple) { const { comments } = responseData; responseData = comments[comments.length - 1]; } diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts index deca2d1e81..a2e4eeb636 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts @@ -44,7 +44,7 @@ export async function elasticSecurityApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { if (error?.error?.error === 'Not Acceptable' && error?.error?.message) { error.error.error = `${error.error.error}: ${error.error.message}`; @@ -89,7 +89,7 @@ export async function handleListing( const returnAll = this.getNodeParameter('returnAll', 0); if (returnAll) { - return await elasticSecurityApiRequestAllItems.call(this, method, endpoint, body, qs); + return elasticSecurityApiRequestAllItems.call(this, method, endpoint, body, qs); } const responseData = await elasticSecurityApiRequestAllItems.call( diff --git a/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts b/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts index 562e96fe27..6e5ea92f0b 100644 --- a/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts +++ b/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts @@ -184,7 +184,7 @@ export class Elasticsearch implements INodeType { responseData = responseData.map((item: IDataObject) => { return { _id: item._id, - ...(item._source as {}), + ...(item._source as IDataObject), }; }); } @@ -331,7 +331,7 @@ 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((i) => ({ indexId: i })); + responseData = Object.keys(responseData).map((index) => ({ indexId: index })); const returnAll = this.getNodeParameter('returnAll', i); diff --git a/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts b/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts index 0a9a32b3a0..726907be08 100644 --- a/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts +++ b/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts @@ -214,8 +214,8 @@ export class EmailReadImapV1 implements INodeType { if (!_.isEmpty(tlsOptions)) { config.imap.tlsOptions = tlsOptions; } - const conn = imapConnect(config).then(async (conn) => { - return conn; + const conn = imapConnect(config).then(async (entry) => { + return entry; }); (await conn).getBoxes((_err, _boxes) => {}); } catch (error) { @@ -271,8 +271,8 @@ export class EmailReadImapV1 implements INodeType { // Returns the email attachments const getAttachment = async ( - connection: ImapSimple, - + imapConnection: ImapSimple, + // tslint:disable-next-line:no-any parts: any[], message: Message, ): Promise => { @@ -288,13 +288,15 @@ export class EmailReadImapV1 implements INodeType { const attachmentPromises = []; let attachmentPromise; for (const attachmentPart of attachmentParts) { - attachmentPromise = connection.getPartData(message, attachmentPart).then((partData) => { - // Return it in the format n8n expects - return this.helpers.prepareBinaryData( - partData, - attachmentPart.disposition.params.filename, - ); - }); + attachmentPromise = imapConnection + .getPartData(message, attachmentPart) + .then(async (partData) => { + // Return it in the format n8n expects + return this.helpers.prepareBinaryData( + partData, + attachmentPart.disposition.params.filename, + ); + }); attachmentPromises.push(attachmentPromise); } @@ -304,7 +306,7 @@ export class EmailReadImapV1 implements INodeType { // Returns all the new unseen messages const getNewEmails = async ( - connection: ImapSimple, + imapConnection: ImapSimple, searchCriteria: Array, ): Promise => { const format = this.getNodeParameter('format', 0) as string; @@ -325,7 +327,7 @@ export class EmailReadImapV1 implements INodeType { }; } - const results = await connection.search(searchCriteria, fetchOptions); + const results = await imapConnection.search(searchCriteria, fetchOptions); const newEmails: INodeExecutionData[] = []; let newEmail: INodeExecutionData, messageHeader, messageBody; @@ -371,7 +373,7 @@ export class EmailReadImapV1 implements INodeType { const downloadAttachments = this.getNodeParameter('downloadAttachments') as boolean; let dataPropertyAttachmentsPrefixName = ''; - if (downloadAttachments === true) { + if (downloadAttachments) { dataPropertyAttachmentsPrefixName = this.getNodeParameter( 'dataPropertyAttachmentsPrefixName', ) as string; @@ -416,9 +418,9 @@ export class EmailReadImapV1 implements INodeType { } } - if (downloadAttachments === true) { + if (downloadAttachments) { // Get attachments and add them if any get found - attachments = await getAttachment(connection, parts, message); + attachments = await getAttachment(imapConnection, parts, message); if (attachments.length) { newEmail.binary = {}; for (let i = 0; i < attachments.length; i++) { @@ -463,15 +465,15 @@ export class EmailReadImapV1 implements INodeType { if (postProcessAction === 'read') { const uidList = results.map((e) => e.attributes.uid); if (uidList.length > 0) { - connection.addFlags(uidList, '\\SEEN'); + await imapConnection.addFlags(uidList, '\\SEEN'); } } return newEmails; }; - const returnedPromise: IDeferredPromise | undefined = await createDeferredPromise(); + const returnedPromise: IDeferredPromise | undefined = await createDeferredPromise(); - const establishConnection = (): Promise => { + const establishConnection = async (): Promise => { let searchCriteria = ['UNSEEN'] as Array; if (options.customEmailConfig !== undefined) { try { @@ -520,7 +522,7 @@ export class EmailReadImapV1 implements INodeType { }); // Wait with resolving till the returnedPromise got resolved, else n8n will be unhappy // if it receives an error before the workflow got activated - returnedPromise.promise().then(() => { + await returnedPromise.promise().then(() => { this.emitError(error as Error); }); } @@ -575,7 +577,7 @@ export class EmailReadImapV1 implements INodeType { if (options.forceReconnect !== undefined) { reconnectionInterval = setInterval(async () => { Logger.verbose('Forcing reconnection of IMAP node.'); - await connection.end(); + connection.end(); connection = await establishConnection(); await connection.openBox(mailbox); }, (options.forceReconnect as number) * 1000 * 60); @@ -586,7 +588,7 @@ export class EmailReadImapV1 implements INodeType { if (reconnectionInterval) { clearInterval(reconnectionInterval); } - await connection.end(); + connection.end(); } // Resolve returned-promise so that waiting errors can be emitted diff --git a/packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts b/packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts index a3dd0b954d..eab1cee969 100644 --- a/packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts +++ b/packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts @@ -202,7 +202,7 @@ export class EmailReadImapV2 implements INodeType { }; const tlsOptions: IDataObject = {}; - if (credentials.allowUnauthorizedCerts === true) { + if (credentials.allowUnauthorizedCerts) { tlsOptions.rejectUnauthorized = false; } @@ -278,7 +278,8 @@ export class EmailReadImapV2 implements INodeType { // Returns the email attachments const getAttachment = async ( - connection: ImapSimple, + imapConnection: ImapSimple, + // tslint:disable-next-line:no-any parts: any[], message: Message, @@ -295,13 +296,15 @@ export class EmailReadImapV2 implements INodeType { const attachmentPromises = []; let attachmentPromise; for (const attachmentPart of attachmentParts) { - attachmentPromise = connection.getPartData(message, attachmentPart).then((partData) => { - // Return it in the format n8n expects - return this.helpers.prepareBinaryData( - partData, - attachmentPart.disposition.params.filename, - ); - }); + attachmentPromise = imapConnection + .getPartData(message, attachmentPart) + .then(async (partData) => { + // Return it in the format n8n expects + return this.helpers.prepareBinaryData( + partData, + attachmentPart.disposition.params.filename, + ); + }); attachmentPromises.push(attachmentPromise); } @@ -311,7 +314,7 @@ export class EmailReadImapV2 implements INodeType { // Returns all the new unseen messages const getNewEmails = async ( - connection: ImapSimple, + imapConnection: ImapSimple, searchCriteria: Array, ): Promise => { const format = this.getNodeParameter('format', 0) as string; @@ -332,7 +335,7 @@ export class EmailReadImapV2 implements INodeType { }; } - const results = await connection.search(searchCriteria, fetchOptions); + const results = await imapConnection.search(searchCriteria, fetchOptions); const newEmails: INodeExecutionData[] = []; let newEmail: INodeExecutionData, messageHeader, messageBody; @@ -378,7 +381,7 @@ export class EmailReadImapV2 implements INodeType { const downloadAttachments = this.getNodeParameter('downloadAttachments') as boolean; let dataPropertyAttachmentsPrefixName = ''; - if (downloadAttachments === true) { + if (downloadAttachments) { dataPropertyAttachmentsPrefixName = this.getNodeParameter( 'dataPropertyAttachmentsPrefixName', ) as string; @@ -423,9 +426,9 @@ export class EmailReadImapV2 implements INodeType { } } - if (downloadAttachments === true) { + if (downloadAttachments) { // Get attachments and add them if any get found - attachments = await getAttachment(connection, parts, message); + attachments = await getAttachment(imapConnection, parts, message); if (attachments.length) { newEmail.binary = {}; for (let i = 0; i < attachments.length; i++) { @@ -470,15 +473,15 @@ export class EmailReadImapV2 implements INodeType { if (postProcessAction === 'read') { const uidList = results.map((e) => e.attributes.uid); if (uidList.length > 0) { - connection.addFlags(uidList, '\\SEEN'); + await imapConnection.addFlags(uidList, '\\SEEN'); } } return newEmails; }; - const returnedPromise: IDeferredPromise | undefined = await createDeferredPromise(); + const returnedPromise: IDeferredPromise | undefined = await createDeferredPromise(); - const establishConnection = (): Promise => { + const establishConnection = async (): Promise => { let searchCriteria = ['UNSEEN'] as Array; if (options.customEmailConfig !== undefined) { try { @@ -527,7 +530,7 @@ export class EmailReadImapV2 implements INodeType { }); // Wait with resolving till the returnedPromise got resolved, else n8n will be unhappy // if it receives an error before the workflow got activated - returnedPromise.promise().then(() => { + await returnedPromise.promise().then(() => { this.emitError(error as Error); }); } @@ -540,12 +543,12 @@ export class EmailReadImapV2 implements INodeType { const tlsOptions: IDataObject = {}; - if (credentials.allowUnauthorizedCerts === true) { + if (credentials.allowUnauthorizedCerts) { tlsOptions.rejectUnauthorized = false; } if (credentials.secure) { - tlsOptions.servername = credentials.host as string; + tlsOptions.servername = credentials.host; } if (!_.isEmpty(tlsOptions)) { @@ -556,9 +559,9 @@ export class EmailReadImapV2 implements INodeType { // that we get informed whenever a new email arrives return imapConnect(config).then(async (conn) => { conn.on('close', async (_hadError: boolean) => { - if (isCurrentlyReconnecting === true) { + if (isCurrentlyReconnecting) { Logger.debug(`Email Read Imap: Connected closed for forced reconnecting`); - } else if (closeFunctionWasCalled === true) { + } else if (closeFunctionWasCalled) { Logger.debug(`Email Read Imap: Shutting down workflow - connected closed`); } else { Logger.error(`Email Read Imap: Connected closed unexpectedly`); @@ -586,7 +589,7 @@ export class EmailReadImapV2 implements INodeType { Logger.verbose(`Forcing reconnect to IMAP server`); try { isCurrentlyReconnecting = true; - if (connection.closeBox) connection.closeBox(false); + if (connection.closeBox) await connection.closeBox(false); connection.end(); connection = await establishConnection(); await connection.openBox(mailbox); @@ -604,7 +607,7 @@ export class EmailReadImapV2 implements INodeType { if (reconnectionInterval) { clearInterval(reconnectionInterval); } - if (connection.closeBox) connection.closeBox(false); + if (connection.closeBox) await connection.closeBox(false); connection.end(); } diff --git a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts index 18667f8767..4ce0c78df8 100644 --- a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts +++ b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts @@ -135,7 +135,7 @@ export class EmailSend implements INodeType { const text = this.getNodeParameter('text', itemIndex) as string; const html = this.getNodeParameter('html', itemIndex) as string; const attachmentPropertyString = this.getNodeParameter('attachments', itemIndex) as string; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); const credentials = await this.getCredentials('smtp'); diff --git a/packages/nodes-base/nodes/Emelia/Emelia.node.ts b/packages/nodes-base/nodes/Emelia/Emelia.node.ts index 464d257194..b70ae88c9d 100644 --- a/packages/nodes-base/nodes/Emelia/Emelia.node.ts +++ b/packages/nodes-base/nodes/Emelia/Emelia.node.ts @@ -110,8 +110,8 @@ export class Emelia implements INodeType { if (additionalFields.customFieldsUi) { const customFields = - (((additionalFields.customFieldsUi as IDataObject) || {}) - .customFieldsValues as IDataObject[]) || []; + ((additionalFields.customFieldsUi as IDataObject) + ?.customFieldsValues as IDataObject[]) || []; const data = customFields.reduce( (obj, value) => Object.assign(obj, { [`${value.fieldName}`]: value.value }), {}, @@ -366,8 +366,8 @@ export class Emelia implements INodeType { if (additionalFields.customFieldsUi) { const customFields = - (((additionalFields.customFieldsUi as IDataObject) || {}) - .customFieldsValues as IDataObject[]) || []; + ((additionalFields.customFieldsUi as IDataObject) + ?.customFieldsValues as IDataObject[]) || []; const data = customFields.reduce( (obj, value) => Object.assign(obj, { [`${value.fieldName}`]: value.value }), {}, diff --git a/packages/nodes-base/nodes/Emelia/GenericFunctions.ts b/packages/nodes-base/nodes/Emelia/GenericFunctions.ts index 528c8ee5ed..461c879784 100644 --- a/packages/nodes-base/nodes/Emelia/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Emelia/GenericFunctions.ts @@ -50,7 +50,7 @@ export async function emeliaApiRequest( }; try { - return await this.helpers.request!.call(this, options); + return this.helpers.request!.call(this, options); } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } diff --git a/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts b/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts index c4df2686ed..f5385dc9e2 100644 --- a/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts +++ b/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts @@ -224,6 +224,7 @@ export class EventbriteTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { @@ -303,7 +304,7 @@ export class EventbriteTrigger implements INodeType { const resolveData = this.getNodeParameter('resolveData', false) as boolean; - if (resolveData === false) { + if (!resolveData) { // Return the data as it got received return { workflowData: [this.helpers.returnJsonArray(req.body)], diff --git a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts index 09d8eb656b..7512c5886e 100644 --- a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts @@ -44,7 +44,7 @@ export async function eventbriteApiRequest( if (authenticationMethod === 'privateKey') { const credentials = await this.getCredentials('eventbriteApi'); - options.headers!['Authorization'] = `Bearer ${credentials.apiKey}`; + options.headers!.Authorization = `Bearer ${credentials.apiKey}`; return await this.helpers.request!(options); } else { return await this.helpers.requestOAuth2!.call(this, 'eventbriteOAuth2Api', options); @@ -76,8 +76,7 @@ export async function eventbriteApiRequestAllItems( query.continuation = responseData.pagination.continuation; returnData.push.apply(returnData, responseData[propertyName]); } while ( - responseData.pagination !== undefined && - responseData.pagination.has_more_items !== undefined && + responseData.pagination?.has_more_items !== undefined && responseData.pagination.has_more_items !== false ); diff --git a/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts b/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts index 61566d5b4f..eef2d8b94c 100644 --- a/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts +++ b/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts @@ -19,7 +19,7 @@ export interface IExecReturnData { * Promisifiy exec manually to also get the exit code * */ -function execPromise(command: string): Promise { +async function execPromise(command: string): Promise { const returnData: IExecReturnData = { error: undefined, exitCode: 0, @@ -85,7 +85,7 @@ export class ExecuteCommand implements INodeType { let command: string; const executeOnce = this.getNodeParameter('executeOnce', 0) as boolean; - if (executeOnce === true) { + if (executeOnce) { items = [items[0]]; } diff --git a/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow.node.ts b/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow.node.ts index 673438ccc0..8272a31418 100644 --- a/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow.node.ts +++ b/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow.node.ts @@ -156,7 +156,7 @@ export class ExecuteWorkflow implements INodeType { let workflowJson; try { - workflowJson = (await fsReadFile(workflowPath, { encoding: 'utf8' })) as string; + workflowJson = await fsReadFile(workflowPath, { encoding: 'utf8' }); } catch (error) { if (error.code === 'ENOENT') { throw new NodeOperationError( diff --git a/packages/nodes-base/nodes/ExecuteWorkflowTrigger/ExecuteWorkflowTrigger.node.ts b/packages/nodes-base/nodes/ExecuteWorkflowTrigger/ExecuteWorkflowTrigger.node.ts index c6ea0b6eeb..14efb8b1d7 100644 --- a/packages/nodes-base/nodes/ExecuteWorkflowTrigger/ExecuteWorkflowTrigger.node.ts +++ b/packages/nodes-base/nodes/ExecuteWorkflowTrigger/ExecuteWorkflowTrigger.node.ts @@ -28,7 +28,7 @@ export class ExecuteWorkflowTrigger implements INodeType { ], }; - execute(this: IExecuteFunctions): Promise { + async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); return this.prepareOutputData(items); diff --git a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts index fa3971f97b..6261bbb94e 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts @@ -1,6 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IDataObject, INodeExecutionData, INodeType, @@ -304,7 +303,7 @@ export class FacebookGraphApi implements INodeType { let graphApiVersion = this.getNodeParameter('graphApiVersion', itemIndex) as string; const node = this.getNodeParameter('node', itemIndex) as string; const edge = this.getNodeParameter('edge', itemIndex) as string; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); if (graphApiVersion !== '') { graphApiVersion += '/'; @@ -324,13 +323,9 @@ export class FacebookGraphApi implements INodeType { json: true, gzip: true, qs: { - access_token: graphApiCredentials!.accessToken, + access_token: graphApiCredentials.accessToken, }, - rejectUnauthorized: !this.getNodeParameter( - 'allowUnauthorizedCerts', - itemIndex, - false, - ) as boolean, + rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false), }; if (options !== undefined) { @@ -400,7 +395,7 @@ export class FacebookGraphApi implements INodeType { ); } - const binaryProperty = item.binary[binaryPropertyName] as IBinaryData; + const binaryProperty = item.binary[binaryPropertyName]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( itemIndex, @@ -421,7 +416,7 @@ export class FacebookGraphApi implements INodeType { // Now that the options are all set make the actual http request response = await this.helpers.request(requestOptions); } catch (error) { - if (this.continueOnFail() === false) { + if (!this.continueOnFail()) { throw new NodeApiError(this.getNode(), error); } @@ -446,7 +441,7 @@ export class FacebookGraphApi implements INodeType { } if (typeof response === 'string') { - if (this.continueOnFail() === false) { + if (!this.continueOnFail()) { throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON.', { itemIndex, }); diff --git a/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts b/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts index 607c31a340..f084e6db21 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts @@ -243,7 +243,7 @@ export class FacebookTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const bodyData = this.getBodyData() as IDataObject; + const bodyData = this.getBodyData(); const query = this.getQueryData() as IDataObject; const res = this.getResponseObject(); const req = this.getRequestObject(); diff --git a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts index ac6a7f264c..78582b7023 100644 --- a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts @@ -35,7 +35,7 @@ export async function facebookApiRequest( credentials = await this.getCredentials('facebookGraphApi'); } - qs.access_token = credentials!.accessToken; + qs.access_token = credentials.accessToken; const options: OptionsWithUri = { headers: { @@ -550,13 +550,10 @@ export function getFields(object: string) { ], } as { [key: string]: any }; - return [{ name: '*', value: '*' }] - .concat(data[object as string] || []) - .map((fieldObject: IDataObject) => ({ - ...fieldObject, - name: - fieldObject.value !== '*' ? capitalCase(fieldObject.value as string) : fieldObject.value, - })); + return [{ name: '*', value: '*' }].concat(data[object] || []).map((fieldObject: IDataObject) => ({ + ...fieldObject, + name: fieldObject.value !== '*' ? capitalCase(fieldObject.value as string) : fieldObject.value, + })); } export function getAllFields(object: string) { diff --git a/packages/nodes-base/nodes/Figma/FigmaTrigger.node.ts b/packages/nodes-base/nodes/Figma/FigmaTrigger.node.ts index b965c502c3..1f7e93e6cd 100644 --- a/packages/nodes-base/nodes/Figma/FigmaTrigger.node.ts +++ b/packages/nodes-base/nodes/Figma/FigmaTrigger.node.ts @@ -127,7 +127,7 @@ export class FigmaTrigger implements INodeType { team_id: teamId, description: `n8n-webhook:${webhookUrl}`, endpoint: webhookUrl, - passcode: randomBytes(10).toString('hex') as string, + passcode: randomBytes(10).toString('hex'), }; const responseData = await figmaApiRequest.call(this, 'POST', endpoint, body); diff --git a/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts b/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts index bee4327b82..d8bd638165 100644 --- a/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts @@ -193,9 +193,8 @@ export async function getToken( const url = `https://${host}/fmi/data/v1/databases/${db}/sessions`; - let requestOptions: OptionsWithUri; // Reset all values - requestOptions = { + const requestOptions: OptionsWithUri = { uri: url, headers: {}, method: 'POST', @@ -203,15 +202,15 @@ export async function getToken( //rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean, }; requestOptions.auth = { - user: login as string, - pass: password as string, + user: login, + pass: password, }; requestOptions.body = { fmDataSource: [ { database: host, - username: login as string, - password: password as string, + username: login, + password, }, ], }; @@ -243,9 +242,8 @@ export async function logout( const url = `https://${host}/fmi/data/v1/databases/${db}/sessions/${token}`; - let requestOptions: OptionsWithUri; // Reset all values - requestOptions = { + const requestOptions: OptionsWithUri = { uri: url, headers: {}, method: 'DELETE', @@ -285,11 +283,11 @@ export function parseSort(this: IExecuteFunctions, i: number): object | null { const sortParametersUi = this.getNodeParameter('sortParametersUi', i, {}) as IDataObject; if (sortParametersUi.rules !== undefined) { // @ts-ignore - for (const parameterData of sortParametersUi!.rules as IDataObject[]) { + for (const parameterData of sortParametersUi.rules as IDataObject[]) { // @ts-ignore sort.push({ - fieldName: parameterData!.name as string, - sortOrder: parameterData!.value, + fieldName: parameterData.name as string, + sortOrder: parameterData.value, }); } } @@ -308,7 +306,7 @@ export function parseScripts(this: IExecuteFunctions, i: number): object | null const scripts = {} as ScriptsOptions; if (setScriptAfter) { scripts.script = this.getNodeParameter('scriptAfter', i); - scripts!['script.param'] = this.getNodeParameter('scriptAfter', i); + scripts['script.param'] = this.getNodeParameter('scriptAfter', i); } if (setScriptBefore) { scripts['script.prerequest'] = this.getNodeParameter('scriptBefore', i); @@ -324,8 +322,8 @@ export function parseScripts(this: IExecuteFunctions, i: number): object | null export function parsePortals(this: IExecuteFunctions, i: number): object | null { let portals; - const getPortals = this.getNodeParameter('getPortals', i); - if (!getPortals) { + const getPortalsData = this.getNodeParameter('getPortals', i); + if (!getPortalsData) { portals = []; } else { portals = this.getNodeParameter('portals', i); @@ -340,14 +338,14 @@ export function parseQuery(this: IExecuteFunctions, i: number): object | null { if (queriesParamUi.query !== undefined) { // @ts-ignore queries = []; - for (const queryParam of queriesParamUi!.query as IDataObject[]) { + for (const queryParam of queriesParamUi.query as IDataObject[]) { const query = { omit: queryParam.omit ? 'true' : 'false', }; // @ts-ignore - for (const field of queryParam!.fields!.field as IDataObject[]) { + for (const field of queryParam.fields!.field as IDataObject[]) { // @ts-ignore - query[field.name] = field!.value; + query[field.name] = field.value; } queries.push(query); } @@ -364,9 +362,9 @@ export function parseFields(this: IExecuteFunctions, i: number): object | null { if (fieldsParametersUi.fields !== undefined) { // @ts-ignore fieldData = {}; - for (const field of fieldsParametersUi!.fields as IDataObject[]) { + for (const field of fieldsParametersUi.fields as IDataObject[]) { // @ts-ignore - fieldData[field.name] = field!.value; + fieldData[field.name] = field.value; } } else { fieldData = null; diff --git a/packages/nodes-base/nodes/Flow/Flow.node.ts b/packages/nodes-base/nodes/Flow/Flow.node.ts index ddc8ba5170..566bed16e0 100644 --- a/packages/nodes-base/nodes/Flow/Flow.node.ts +++ b/packages/nodes-base/nodes/Flow/Flow.node.ts @@ -7,7 +7,7 @@ import { NodeApiError, } from 'n8n-workflow'; import { flowApiRequest, FlowApiRequestAllItems } from './GenericFunctions'; -import { taskFields, taskOpeations } from './TaskDescription'; +import { taskFields, taskOperations } from './TaskDescription'; import { ITask, TaskInfo } from './TaskInterface'; export class Flow implements INodeType { @@ -47,7 +47,7 @@ export class Flow implements INodeType { ], default: 'task', }, - ...taskOpeations, + ...taskOperations, ...taskFields, ], }; @@ -242,7 +242,7 @@ export class Flow implements INodeType { qs.cleared = filters.cleared as boolean; } try { - if (returnAll === true) { + if (returnAll) { responseData = await FlowApiRequestAllItems.call( this, 'tasks', diff --git a/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts b/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts index b5b1b658cf..b7c5059281 100644 --- a/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts +++ b/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts @@ -85,6 +85,7 @@ export class FlowTrigger implements INodeType { }, ], }; + // @ts-ignore webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/Flow/TaskDescription.ts b/packages/nodes-base/nodes/Flow/TaskDescription.ts index fd7ba34f42..bdd5b32f95 100644 --- a/packages/nodes-base/nodes/Flow/TaskDescription.ts +++ b/packages/nodes-base/nodes/Flow/TaskDescription.ts @@ -1,6 +1,6 @@ import { INodeProperties } from 'n8n-workflow'; -export const taskOpeations: INodeProperties[] = [ +export const taskOperations: INodeProperties[] = [ { displayName: 'Operation', name: 'operation', diff --git a/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts b/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts index 38d0213995..de2c30b752 100644 --- a/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts +++ b/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts @@ -201,7 +201,7 @@ export class FormIoTrigger implements INodeType { const req = this.getRequestObject(); const simple = this.getNodeParameter('simple') as boolean; let response = req.body.request; - if (simple === true) { + if (simple) { response = response.data; } return { diff --git a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts index 21d4fff976..bd76980b4e 100644 --- a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts @@ -72,7 +72,7 @@ export async function formIoApiRequest( }; try { - return await this.helpers.request!.call(this, options); + return this.helpers.request!.call(this, options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts index a64a42d85f..fd57ae5e62 100644 --- a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts @@ -73,7 +73,7 @@ export async function apiRequest( if (authenticationMethod === 'accessToken') { const credentials = (await this.getCredentials('formstackApi')) as IDataObject; - options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; + options.headers!.Authorization = `Bearer ${credentials.accessToken}`; return await this.helpers.request!(options); } else { return await this.helpers.requestOAuth2!.call(this, 'formstackOAuth2Api', options); diff --git a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts index 4ac9eb451c..4aa3b52ba2 100644 --- a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts +++ b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts @@ -1213,17 +1213,17 @@ export class Freshdesk implements INodeType { itemIndex: i, }); } - body.requester_id = parseInt(value as string, 10); + body.requester_id = parseInt(value, 10); } else if (updateFields.requester === 'email') { - body.email = value as string; + body.email = value; } else if (updateFields.requester === 'facebookId') { - body.facebook_id = value as string; + body.facebook_id = value; } else if (updateFields.requester === 'phone') { - body.phone = value as string; + body.phone = value; } else if (updateFields.requester === 'twitterId') { - body.twitter_id = value as string; + body.twitter_id = value; } else if (updateFields.requester === 'uniqueExternalId') { - body.unique_external_id = value as string; + body.unique_external_id = value; } } if (updateFields.status) { @@ -1310,7 +1310,7 @@ export class Freshdesk implements INodeType { qs.include = (options.include as string[]).join(','); } } - if (returnAll === true) { + if (returnAll) { responseData = await freshdeskApiRequestAllItems.call( this, 'GET', @@ -1333,11 +1333,7 @@ export class Freshdesk implements INodeType { if (operation === 'create') { const name = this.getNodeParameter('name', i) as string; const email = this.getNodeParameter('email', i) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - {}, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); if (additionalFields.customFields) { const metadata = (additionalFields.customFields as IDataObject) @@ -1375,16 +1371,12 @@ export class Freshdesk implements INodeType { ); //https://developers.freshdesk.com/api/#list_all_contacts } else if (operation === 'getAll') { - const qs = this.getNodeParameter('filters', i, {}) as IDataObject; - responseData = await freshdeskApiRequest.call(this, 'GET', '/contacts', {}, qs); + const filters = this.getNodeParameter('filters', i, {}); + responseData = await freshdeskApiRequest.call(this, 'GET', '/contacts', {}, filters); //https://developers.freshdesk.com/api/#update_contact } else if (operation === 'update') { const contactId = this.getNodeParameter('contactId', i) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - {}, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); if (additionalFields.customFields) { const metadata = (additionalFields.customFields as IDataObject) diff --git a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts index c4a306187b..69e0c7468a 100644 --- a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts @@ -63,13 +63,10 @@ export async function freshdeskApiRequestAllItems( resolveWithFullResponse: true, }); if (responseData.headers.link) { - uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', ''); + uri = responseData.headers.link.split(';')[0].replace('<', '').replace('>', ''); } returnData.push.apply(returnData, responseData.body); - } while ( - responseData.headers['link'] !== undefined && - responseData.headers['link'].includes('rel="next"') - ); + } while (responseData.headers.link?.includes('rel="next"')); return returnData; } diff --git a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts index fc80796075..4fe1fc1032 100644 --- a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts @@ -45,7 +45,7 @@ export async function freshserviceApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { if (error.error.description === 'Validation failed') { const numberOfErrors = error.error.errors.length; @@ -102,7 +102,7 @@ export async function handleListing( const returnAll = this.getNodeParameter('returnAll', 0); if (returnAll) { - return await freshserviceApiRequestAllItems.call(this, method, endpoint, body, qs); + return freshserviceApiRequestAllItems.call(this, method, endpoint, body, qs); } const responseData = await freshserviceApiRequestAllItems.call(this, method, endpoint, body, qs); diff --git a/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts b/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts index 387d1ee296..6176f2dff2 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts @@ -141,15 +141,15 @@ export class FreshworksCrm implements INodeType { }, async getBusinessTypes(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'business_types'); + return loadResource.call(this, 'business_types'); }, async getCampaigns(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'campaigns'); + return loadResource.call(this, 'campaigns'); }, async getContactStatuses(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'contact_statuses'); + return loadResource.call(this, 'contact_statuses'); }, async getContactViews(this: ILoadOptionsFunctions) { @@ -171,27 +171,27 @@ export class FreshworksCrm implements INodeType { }, async getDealPaymentStatuses(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'deal_payment_statuses'); + return loadResource.call(this, 'deal_payment_statuses'); }, async getDealPipelines(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'deal_pipelines'); + return loadResource.call(this, 'deal_pipelines'); }, async getDealProducts(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'deal_products'); + return loadResource.call(this, 'deal_products'); }, async getDealReasons(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'deal_reasons'); + return loadResource.call(this, 'deal_reasons'); }, async getDealStages(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'deal_stages'); + return loadResource.call(this, 'deal_stages'); }, async getDealTypes(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'deal_types'); + return loadResource.call(this, 'deal_types'); }, async getDealViews(this: ILoadOptionsFunctions) { @@ -201,23 +201,23 @@ export class FreshworksCrm implements INodeType { }, async getIndustryTypes(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'industry_types'); + return loadResource.call(this, 'industry_types'); }, async getLifecycleStages(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'lifecycle_stages'); + return loadResource.call(this, 'lifecycle_stages'); }, async getOutcomes(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'sales_activity_outcomes'); + return loadResource.call(this, 'sales_activity_outcomes'); }, async getSalesActivityTypes(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'sales_activity_types'); + return loadResource.call(this, 'sales_activity_types'); }, async getTerritories(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'territories'); + return loadResource.call(this, 'territories'); }, async getUsers(this: ILoadOptionsFunctions) { @@ -379,7 +379,7 @@ export class FreshworksCrm implements INodeType { Object.assign(body, additionalFields); if (attendees.length) { - body['appointment_attendees_attributes'] = adjustAttendees(attendees); + body.appointment_attendees_attributes = adjustAttendees(attendees); } responseData = await freshworksCrmApiRequest.call(this, 'POST', '/appointments', body); responseData = responseData.appointment; @@ -466,7 +466,7 @@ export class FreshworksCrm implements INodeType { Object.assign(body, rest); if (attendees.length) { - body['appointment_attendees_attributes'] = adjustAttendees(attendees); + body.appointment_attendees_attributes = adjustAttendees(attendees); delete body.attendees; } diff --git a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts index 436480cde0..3b75d7e4da 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts @@ -107,7 +107,7 @@ export async function handleListing( const returnAll = this.getNodeParameter('returnAll', 0); if (returnAll) { - return await freshworksCrmApiRequestAllItems.call(this, method, endpoint, body, qs); + return freshworksCrmApiRequestAllItems.call(this, method, endpoint, body, qs); } const responseData = await freshworksCrmApiRequestAllItems.call(this, method, endpoint, body, qs); diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/AppointmentDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/AppointmentDescription.ts index aa2bc869b0..a525d0e922 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/AppointmentDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/descriptions/AppointmentDescription.ts @@ -260,7 +260,7 @@ export const appointmentFields: INodeProperties[] = [ type: 'options', default: '', description: 'Timezone that the appointment is scheduled in', - options: tz.names().map((tz) => ({ name: tz, value: tz })), + options: tz.names().map((timeZone) => ({ name: timeZone, value: timeZone })), }, ], }, @@ -576,7 +576,7 @@ export const appointmentFields: INodeProperties[] = [ type: 'options', default: '', description: 'Timezone that the appointment is scheduled in', - options: tz.names().map((tz) => ({ name: tz, value: tz })), + options: tz.names().map((timeZone) => ({ name: timeZone, value: timeZone })), }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/Ftp/Ftp.node.ts b/packages/nodes-base/nodes/Ftp/Ftp.node.ts index 1154568529..7053b56f2e 100644 --- a/packages/nodes-base/nodes/Ftp/Ftp.node.ts +++ b/packages/nodes-base/nodes/Ftp/Ftp.node.ts @@ -361,8 +361,7 @@ export class Ftp implements INodeType { ): Promise { const credentials = credential.data as ICredentialDataDecryptedObject; try { - let ftp: ftpClient; - ftp = new ftpClient(); + const ftp = new ftpClient(); await ftp.connect({ host: credentials.host as string, port: credentials.port as number, @@ -386,8 +385,7 @@ export class Ftp implements INodeType { ): Promise { const credentials = credential.data as ICredentialDataDecryptedObject; try { - let sftp: sftpClient; - sftp = new sftpClient(); + const sftp = new sftpClient(); await sftp.connect({ host: credentials.host as string, port: credentials.port as number, @@ -478,7 +476,7 @@ export class Ftp implements INodeType { ); } else { responseData = await sftp!.list(path); - responseData.forEach((item) => normalizeSFtpItem(item as sftpClient.FileInfo, path)); + responseData.forEach((item) => normalizeSFtpItem(item, path)); returnItems.push.apply( returnItems, this.helpers.returnJsonArray(responseData as unknown as IDataObject[]), @@ -538,7 +536,7 @@ export class Ftp implements INodeType { const remotePath = this.getNodeParameter('path', i) as string; await recursivelyCreateSftpDirs(sftp!, remotePath); - if (this.getNodeParameter('binaryData', i) === true) { + if (this.getNodeParameter('binaryData', i)) { // Is binary file to upload const item = items[i]; @@ -562,10 +560,7 @@ export class Ftp implements INodeType { await sftp!.put(buffer, remotePath); } else { // Is text file - const buffer = Buffer.from( - this.getNodeParameter('fileContent', i) as string, - 'utf8', - ) as Buffer; + const buffer = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8'); await sftp!.put(buffer, remotePath); } @@ -653,7 +648,7 @@ export class Ftp implements INodeType { const fileName = basename(remotePath); const dirPath = remotePath.replace(fileName, ''); - if (this.getNodeParameter('binaryData', i) === true) { + if (this.getNodeParameter('binaryData', i)) { // Is binary file to upload const item = items[i]; @@ -688,10 +683,7 @@ export class Ftp implements INodeType { } } else { // Is text file - const buffer = Buffer.from( - this.getNodeParameter('fileContent', i) as string, - 'utf8', - ) as Buffer; + const buffer = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8'); try { await ftp!.put(buffer, remotePath); } catch (error) { @@ -754,26 +746,29 @@ async function callRecursiveList( const directoryItems: sftpClient.FileInfo[] = []; let index = 0; + const prepareAndNormalize = (item: sftpClient.FileInfo) => { + if (pathArray[index].endsWith('/')) { + currentPath = `${pathArray[index]}${item.name}`; + } else { + currentPath = `${pathArray[index]}/${item.name}`; + } + + // Is directory + if (item.type === 'd') { + pathArray.push(currentPath); + } + + normalizeFunction(item as ftpClient.ListingElement & sftpClient.FileInfo, currentPath, true); + directoryItems.push(item); + }; + do { - const returnData: sftpClient.FileInfo[] | (string | ftpClient.ListingElement)[] = + // tslint:disable-next-line: array-type + const returnData: sftpClient.FileInfo[] | Array = await client.list(pathArray[index]); // @ts-ignore - returnData.map((item: sftpClient.FileInfo) => { - if ((pathArray[index] as string).endsWith('/')) { - currentPath = `${pathArray[index]}${item.name}`; - } else { - currentPath = `${pathArray[index]}/${item.name}`; - } - - // Is directory - if (item.type === 'd') { - pathArray.push(currentPath); - } - - normalizeFunction(item as ftpClient.ListingElement & sftpClient.FileInfo, currentPath, true); - directoryItems.push(item); - }); + returnData.map(prepareAndNormalize); index++; } while (index <= pathArray.length - 1); @@ -782,9 +777,9 @@ async function callRecursiveList( async function recursivelyCreateSftpDirs(sftp: sftpClient, path: string) { const dirPath = dirname(path); - const dirExists = await sftp!.exists(dirPath); + const dirExists = await sftp.exists(dirPath); if (!dirExists) { - await sftp!.mkdir(dirPath, true); + await sftp.mkdir(dirPath, true); } } diff --git a/packages/nodes-base/nodes/Function/Function.node.ts b/packages/nodes-base/nodes/Function/Function.node.ts index 73645c7195..97f81c1d76 100644 --- a/packages/nodes-base/nodes/Function/Function.node.ts +++ b/packages/nodes-base/nodes/Function/Function.node.ts @@ -103,7 +103,7 @@ return items;`, if (item?.binary && item?.index !== undefined && item?.index !== null) { for (const binaryPropertyName of Object.keys(item.binary)) { item.binary[binaryPropertyName].data = ( - await this.helpers.getBinaryDataBuffer(item.index as number, binaryPropertyName) + await this.helpers.getBinaryDataBuffer(item.index, binaryPropertyName) )?.toString('base64'); } } diff --git a/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts b/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts index 4527fc59c6..b7c967c5b3 100644 --- a/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts +++ b/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-loop-func */ import { IExecuteFunctions } from 'n8n-core'; import { deepCopy, @@ -121,7 +122,7 @@ return item;`, if (item?.binary && item?.index !== undefined && item?.index !== null) { for (const binaryPropertyName of Object.keys(item.binary)) { item.binary[binaryPropertyName].data = ( - await this.helpers.getBinaryDataBuffer(item.index as number, binaryPropertyName) + await this.helpers.getBinaryDataBuffer(item.index, binaryPropertyName) )?.toString('base64'); } } diff --git a/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts b/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts index 9e22b689c8..5e8d606088 100644 --- a/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts +++ b/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts @@ -162,9 +162,9 @@ export class GetResponse implements INodeType { .customFieldValues as IDataObject[]; if (customFieldValues) { body.customFieldValues = customFieldValues; - for (let i = 0; i < customFieldValues.length; i++) { - if (!Array.isArray(customFieldValues[i].value)) { - customFieldValues[i].value = [customFieldValues[i].value]; + for (let index = 0; index < customFieldValues.length; index++) { + if (!Array.isArray(customFieldValues[index].value)) { + customFieldValues[index].value = [customFieldValues[index].value]; } } delete body.customFieldsUi; @@ -248,7 +248,7 @@ export class GetResponse implements INodeType { } if (qs.exactMatch === true) { - qs['additionalFlags'] = 'exactMatch'; + qs.additionalFlags = 'exactMatch'; delete qs.exactMatch; } diff --git a/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts b/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts index 38ef0ade3c..c8d901bb9b 100644 --- a/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts +++ b/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts @@ -165,7 +165,7 @@ export class GetResponseTrigger implements INodeType { const data = await getresponseApiRequest.call(this, 'GET', '/accounts/callbacks', {}); if (data.url !== webhookUrl) { - if (deleteCurrentSubscription === false) { + if (!deleteCurrentSubscription) { throw new NodeApiError(this.getNode(), data, { 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.`, }); @@ -216,7 +216,7 @@ export class GetResponseTrigger implements INodeType { const query = this.getQueryData() as IDataObject; const listIds = this.getNodeParameter('listIds') as string[]; - if (!listIds.includes('*') && !listIds.includes(query['CAMPAIGN_ID'] as string)) { + if (!listIds.includes('*') && !listIds.includes(query.CAMPAIGN_ID as string)) { return {}; } diff --git a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts index 28a34ed03d..e46442ac1a 100644 --- a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts @@ -20,7 +20,6 @@ export async function ghostApiRequest( ): Promise { const source = this.getNodeParameter('source', 0) as string; - let credentials; let version; let credentialType; @@ -33,7 +32,7 @@ export async function ghostApiRequest( credentialType = 'ghostAdminApi'; } - credentials = await this.getCredentials(credentialType); + const credentials = await this.getCredentials(credentialType); const options: OptionsWithUri = { method, diff --git a/packages/nodes-base/nodes/Git/Git.node.ts b/packages/nodes-base/nodes/Git/Git.node.ts index 38594c5fe3..dc0c8165c8 100644 --- a/packages/nodes-base/nodes/Git/Git.node.ts +++ b/packages/nodes-base/nodes/Git/Git.node.ts @@ -1,5 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; -import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; +import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; import { addConfigFields, @@ -219,7 +219,7 @@ export class Git implements INodeType { _item = items[itemIndex]; const repositoryPath = this.getNodeParameter('repositoryPath', itemIndex, '') as string; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); if (operation === 'clone') { // Create repository folder if it does not exist @@ -340,8 +340,8 @@ export class Git implements INodeType { const logOptions: LogOptions = {}; - const returnAll = this.getNodeParameter('returnAll', itemIndex, false) as boolean; - if (returnAll === false) { + const returnAll = this.getNodeParameter('returnAll', itemIndex, false); + if (!returnAll) { logOptions.maxCount = this.getNodeParameter('limit', itemIndex, 100); } if (options.file) { diff --git a/packages/nodes-base/nodes/Github/GenericFunctions.ts b/packages/nodes-base/nodes/Github/GenericFunctions.ts index da1b5272bd..7e258e5058 100644 --- a/packages/nodes-base/nodes/Github/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Github/GenericFunctions.ts @@ -43,7 +43,7 @@ export async function githubApiRequest( const credentials = await this.getCredentials('githubApi'); credentialType = 'githubApi'; - const baseUrl = credentials!.server || 'https://api.github.com'; + const baseUrl = credentials.server || 'https://api.github.com'; options.uri = `${baseUrl}${endpoint}`; } else { const credentials = await this.getCredentials('githubOAuth2Api'); @@ -105,6 +105,6 @@ export async function githubApiRequestAllItems( }); query.page++; returnData.push.apply(returnData, responseData.body); - } while (responseData.headers.link && responseData.headers.link.includes('next')); + } 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 dbd39bdfc0..1122e049c9 100644 --- a/packages/nodes-base/nodes/Github/Github.node.ts +++ b/packages/nodes-base/nodes/Github/Github.node.ts @@ -1727,7 +1727,7 @@ export class Github implements INodeType { body.message = this.getNodeParameter('commitMessage', i) as string; - if (this.getNodeParameter('binaryData', i) === true) { + if (this.getNodeParameter('binaryData', i)) { // Is binary file to upload const item = items[i]; @@ -1829,8 +1829,8 @@ export class Github implements INodeType { const assignees = this.getNodeParameter('assignees', i) as IDataObject[]; - body.labels = labels.map((data) => data['label']); - body.assignees = assignees.map((data) => data['assignee']); + body.labels = labels.map((data) => data.label); + body.assignees = assignees.map((data) => data.assignee); endpoint = `/repos/${owner}/${repository}/issues`; } else if (operation === 'createComment') { @@ -1856,10 +1856,10 @@ export class Github implements INodeType { body = this.getNodeParameter('editFields', i, {}) as IDataObject; if (body.labels !== undefined) { - body.labels = (body.labels as IDataObject[]).map((data) => data['label']); + body.labels = (body.labels as IDataObject[]).map((data) => data.label); } if (body.assignees !== undefined) { - body.assignees = (body.assignees as IDataObject[]).map((data) => data['assignee']); + body.assignees = (body.assignees as IDataObject[]).map((data) => data.assignee); } endpoint = `/repos/${owner}/${repository}/issues/${issueNumber}`; @@ -1894,7 +1894,7 @@ export class Github implements INodeType { requestMethod = 'POST'; - body = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + body = this.getNodeParameter('additionalFields', i, {}); body.tag_name = this.getNodeParameter('releaseTag', i) as string; @@ -1933,7 +1933,7 @@ export class Github implements INodeType { returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', 0); } } @@ -1946,7 +1946,7 @@ export class Github implements INodeType { const releaseId = this.getNodeParameter('release_id', i) as string; - body = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + body = this.getNodeParameter('additionalFields', i, {}); endpoint = `/repos/${owner}/${repository}/releases/${releaseId}`; } @@ -1996,7 +1996,7 @@ export class Github implements INodeType { returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', 0); } } @@ -2022,7 +2022,7 @@ export class Github implements INodeType { const pullRequestNumber = this.getNodeParameter('pullRequestNumber', i) as string; - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', 0); } @@ -2068,7 +2068,7 @@ export class Github implements INodeType { returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', 0); } } else if (operation === 'invite') { @@ -2092,7 +2092,7 @@ export class Github implements INodeType { endpoint = `/orgs/${owner}/repos`; returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', 0); } } @@ -2103,7 +2103,7 @@ export class Github implements INodeType { } const asBinaryProperty = this.getNodeParameter('asBinaryProperty', i, false) as boolean; - if (returnAll === true) { + if (returnAll) { responseData = await githubApiRequestAllItems.call( this, requestMethod, @@ -2116,7 +2116,7 @@ export class Github implements INodeType { } if (fullOperation === 'file:get') { - if (asBinaryProperty === true) { + if (asBinaryProperty) { if (Array.isArray(responseData) && responseData.length > 1) { throw new NodeOperationError(this.getNode(), 'File Path is a folder, not a file.', { itemIndex: i, diff --git a/packages/nodes-base/nodes/Github/GithubTrigger.node.ts b/packages/nodes-base/nodes/Github/GithubTrigger.node.ts index 1d059160d9..7b7283984a 100644 --- a/packages/nodes-base/nodes/Github/GithubTrigger.node.ts +++ b/packages/nodes-base/nodes/Github/GithubTrigger.node.ts @@ -419,7 +419,7 @@ export class GithubTrigger implements INodeType { responseData = await githubApiRequest.call(this, 'GET', endpoint, body); for (const webhook of responseData as IDataObject[]) { - if ((webhook!.config! as IDataObject).url! === webhookUrl) { + if ((webhook.config! as IDataObject).url! === webhookUrl) { // Webhook got found if (JSON.stringify(webhook.events) === JSON.stringify(events)) { // Webhook with same events exists already so no need to diff --git a/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts b/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts index 5505212043..48b1f2e664 100644 --- a/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts @@ -43,7 +43,7 @@ export async function gitlabApiRequest( options.uri = `${(credentials.server as string).replace(/\/$/, '')}/api/v4${endpoint}`; - return await this.helpers.requestOAuth2!.call(this, 'gitlabOAuth2Api', options); + return await this.helpers.requestOAuth2.call(this, 'gitlabOAuth2Api', options); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -71,6 +71,6 @@ export async function gitlabApiRequestAllItems( }); query.page++; returnData.push.apply(returnData, responseData.body); - } while (responseData.headers.link && responseData.headers.link.includes('next')); + } 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 eb6d11cc2e..f727e8c609 100644 --- a/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts +++ b/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts @@ -1065,8 +1065,8 @@ export class Gitlab implements INodeType { const assigneeIds = this.getNodeParameter('assignee_ids', i) as IDataObject[]; - body.labels = labels.map((data) => data['label']).join(','); - body.assignee_ids = assigneeIds.map((data) => data['assignee']); + body.labels = labels.map((data) => data.label).join(','); + body.assignee_ids = assigneeIds.map((data) => data.assignee); endpoint = `${baseEndpoint}/issues`; } else if (operation === 'createComment') { @@ -1092,12 +1092,10 @@ export class Gitlab implements INodeType { body = this.getNodeParameter('editFields', i, {}) as IDataObject; if (body.labels !== undefined) { - body.labels = (body.labels as IDataObject[]).map((data) => data['label']).join(','); + body.labels = (body.labels as IDataObject[]).map((data) => data.label).join(','); } if (body.assignee_ids !== undefined) { - body.assignee_ids = (body.assignee_ids as IDataObject[]).map( - (data) => data['assignee'], - ); + body.assignee_ids = (body.assignee_ids as IDataObject[]).map((data) => data.assignee); } endpoint = `${baseEndpoint}/issues/${issueNumber}`; @@ -1132,7 +1130,7 @@ export class Gitlab implements INodeType { requestMethod = 'POST'; - body = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + body = this.getNodeParameter('additionalFields', i, {}); body.tag_name = this.getNodeParameter('releaseTag', i) as string; @@ -1173,11 +1171,11 @@ export class Gitlab implements INodeType { const id = this.getNodeParameter('projectId', i) as string; - qs = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + qs = this.getNodeParameter('additionalFields', i, {}); returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', 0); } @@ -1194,7 +1192,7 @@ export class Gitlab implements INodeType { const tagName = this.getNodeParameter('tag_name', i) as string; - body = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + body = this.getNodeParameter('additionalFields', i, {}); if (body.milestones) { body.milestones = (body.milestones as string).split(','); } @@ -1237,7 +1235,7 @@ export class Gitlab implements INodeType { }); } - if (returnAll === true) { + if (returnAll) { responseData = await gitlabApiRequestAllItems.call( this, requestMethod, diff --git a/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts b/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts index f97bb43163..a5d72cfb53 100644 --- a/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts +++ b/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts @@ -232,8 +232,8 @@ export class GitlabTrigger implements INodeType { // gitlab set the push_events to true when the field it's not sent. // set it to false when it's not picked by the user. - if (events['push_events'] === undefined) { - events['push_events'] = false; + if (events.push_events === undefined) { + events.push_events = false; } const path = `${owner}/${repository}`.replace(/\//g, '%2F'); @@ -262,7 +262,7 @@ export class GitlabTrigger implements INodeType { const webhookData = this.getWorkflowStaticData('node'); webhookData.webhookId = responseData.id as string; - webhookData.webhookEvents = eventsArray as string[]; + webhookData.webhookEvents = eventsArray; return true; }, diff --git a/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts b/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts index 2bea511e75..7ddec2611a 100644 --- a/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts @@ -41,7 +41,7 @@ export async function goToWebinarApiRequest( }; if (resource === 'session' && operation === 'getAll') { - options.headers!['Accept'] = 'application/vnd.citrix.g2wapi-v1.1+json'; + options.headers!.Accept = 'application/vnd.citrix.g2wapi-v1.1+json'; } if (['GET', 'DELETE'].includes(method)) { @@ -98,7 +98,7 @@ export async function goToWebinarApiRequestAllItems( if (responseData.page && parseInt(responseData.page.totalElements, 10) === 0) { return []; - } else if (responseData._embedded && responseData._embedded[key]) { + } else if (responseData._embedded?.[key]) { returnData.push(...responseData._embedded[key]); } else { returnData.push(...responseData); @@ -129,7 +129,7 @@ export async function handleGetAll( qs.limit = this.getNodeParameter('limit', 0); } - return await goToWebinarApiRequestAllItems.call(this, 'GET', endpoint, qs, body, resource); + return goToWebinarApiRequestAllItems.call(this, 'GET', endpoint, qs, body, resource); } export async function loadWebinars(this: ILoadOptionsFunctions) { @@ -277,7 +277,7 @@ export async function loadRegistranMultiChoiceQuestions(this: ILoadOptionsFuncti } function convertLosslessNumber(key: any, value: any) { - if (value && value.isLosslessNumber) { + if (value?.isLosslessNumber) { return value.toString(); } else { return value; diff --git a/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts b/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts index 21aad41542..69a4e40d47 100644 --- a/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts +++ b/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts @@ -112,13 +112,13 @@ export class GoToWebinar implements INodeType { methods = { loadOptions: { async getWebinars(this: ILoadOptionsFunctions) { - return await loadWebinars.call(this); + return loadWebinars.call(this); }, async getAnswers(this: ILoadOptionsFunctions) { - return await loadAnswers.call(this); + return loadAnswers.call(this); }, async getWebinarSessions(this: ILoadOptionsFunctions) { - return await loadWebinarSessions.call(this); + return loadWebinarSessions.call(this); }, // Get all the timezones to display them to user so that he can // select them easily @@ -137,12 +137,12 @@ export class GoToWebinar implements INodeType { async getRegistranSimpleQuestions( this: ILoadOptionsFunctions, ): Promise { - return await loadRegistranSimpleQuestions.call(this); + return loadRegistranSimpleQuestions.call(this); }, async getRegistranMultiChoiceQuestions( this: ILoadOptionsFunctions, ): Promise { - return await loadRegistranMultiChoiceQuestions.call(this); + return loadRegistranMultiChoiceQuestions.call(this); }, }, }; @@ -533,10 +533,7 @@ export class GoToWebinar implements INodeType { const webinarKey = this.getNodeParameter('webinarKey', i) as string; - const { sendCancellationEmails } = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const { sendCancellationEmails } = this.getNodeParameter('additionalFields', i); const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/Google/Ads/CampaignDescription.ts b/packages/nodes-base/nodes/Google/Ads/CampaignDescription.ts index d8874f8cc8..156e26134f 100644 --- a/packages/nodes-base/nodes/Google/Ads/CampaignDescription.ts +++ b/packages/nodes-base/nodes/Google/Ads/CampaignDescription.ts @@ -1,5 +1,5 @@ -import { IDataObject } from 'n8n-workflow'; import { + IDataObject, IExecuteSingleFunctions, IN8nHttpFullResponse, INodeExecutionData, @@ -263,7 +263,7 @@ export const campaignFields: INodeProperties[] = [ }, ]; -function processCampaignSearchResponse( +async function processCampaignSearchResponse( this: IExecuteSingleFunctions, _inputData: INodeExecutionData[], responseData: IN8nHttpFullResponse, diff --git a/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts index ddb8a44439..04a73fe63e 100644 --- a/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts @@ -58,16 +58,14 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); if (body.reportRequests && Array.isArray(body.reportRequests)) { - body.reportRequests[0]['pageToken'] = responseData[propertyName][0].nextPageToken; + body.reportRequests[0].pageToken = responseData[propertyName][0].nextPageToken; } else { - body.pageToken = responseData['nextPageToken']; + body.pageToken = responseData.nextPageToken; } returnData.push.apply(returnData, responseData[propertyName]); } while ( - (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== '') || - (responseData[propertyName] && - responseData[propertyName][0].nextPageToken && - responseData[propertyName][0].nextPageToken !== undefined) + (responseData.nextPageToken !== undefined && responseData.nextPageToken !== '') || + responseData[propertyName]?.[0].nextPageToken !== undefined ); return returnData; @@ -88,10 +86,10 @@ export function simplify(responseData: any | [any]) { if (dimensions) { for (let i = 0; i < dimensions.length; i++) { data[dimensions[i]] = row.dimensions[i]; - data['total'] = row.metrics[0].values.join(','); + data.total = row.metrics[0].values.join(','); } } else { - data['total'] = row.metrics[0].values.join(','); + data.total = row.metrics[0].values.join(','); } response.push(data); } diff --git a/packages/nodes-base/nodes/Google/Analytics/GoogleAnalytics.node.ts b/packages/nodes-base/nodes/Google/Analytics/GoogleAnalytics.node.ts index 8bce66a3d4..dd7e26e057 100644 --- a/packages/nodes-base/nodes/Google/Analytics/GoogleAnalytics.node.ts +++ b/packages/nodes-base/nodes/Google/Analytics/GoogleAnalytics.node.ts @@ -215,7 +215,7 @@ export class GoogleAnalytics implements INodeType { Object.assign(body, { hideTotals: additionalFields.hideTotals }); } - if (returnAll === true) { + if (returnAll) { responseData = await googleApiRequestAllItems.call( this, 'reports', @@ -235,9 +235,9 @@ export class GoogleAnalytics implements INodeType { responseData = responseData.reports; } - if (simple === true) { + if (simple) { responseData = simplify(responseData); - } else if (returnAll === true && responseData.length > 1) { + } else if (returnAll && responseData.length > 1) { responseData = merge(responseData); } } diff --git a/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts b/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts index 82e50e1a68..f67a3d5ac2 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts @@ -82,14 +82,14 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['pageToken']; + query.pageToken = responseData.pageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['pageToken'] !== undefined && responseData['pageToken'] !== ''); + } while (responseData.pageToken !== undefined && responseData.pageToken !== ''); return returnData; } -function getAccessToken( +async function getAccessToken( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IDataObject, ): Promise { diff --git a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts index 0e422d70d2..7ffeed8b1d 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts @@ -220,7 +220,7 @@ export class GoogleBigQuery implements INodeType { const simple = this.getNodeParameter('simple', 0) as boolean; let fields; - if (simple === true) { + if (simple) { const { schema } = await googleApiRequest.call( this, 'GET', diff --git a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts index 0581fe5634..c202e3e66b 100644 --- a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts @@ -97,7 +97,7 @@ export async function googleApiRequestAllItems( return returnData; } -function getAccessToken( +async function getAccessToken( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IGoogleAuthCredentials, ): Promise { @@ -108,22 +108,22 @@ function getAccessToken( const now = moment().unix(); credentials.email = credentials.email.trim(); - const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); + const privateKey = credentials.privateKey.replace(/\\n/g, '\n').trim(); const signature = jwt.sign( { - iss: credentials.email as string, - sub: credentials.delegatedEmail || (credentials.email as string), + iss: credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: `https://oauth2.googleapis.com/token`, iat: now, exp: now + 3600, }, - privateKey as string, + privateKey, { algorithm: 'RS256', header: { - kid: privateKey as string, + kid: privateKey, typ: 'JWT', alg: 'RS256', }, @@ -143,6 +143,5 @@ function getAccessToken( json: true, }; - //@ts-ignore - return this.helpers.request(options); + return this.helpers.request!(options); } diff --git a/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts b/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts index cad53729d7..15376f462a 100644 --- a/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts +++ b/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts @@ -386,7 +386,7 @@ export class GoogleBooks implements INodeType { const shelfId = this.getNodeParameter('shelfId', i) as string; const myLibrary = this.getNodeParameter('myLibrary', i) as boolean; let endpoint; - if (myLibrary === false) { + if (!myLibrary) { const userId = this.getNodeParameter('userId', i) as string; endpoint = `v1/users/${userId}/bookshelves/${shelfId}`; } else { @@ -398,7 +398,7 @@ export class GoogleBooks implements INodeType { const myLibrary = this.getNodeParameter('myLibrary', i) as boolean; const returnAll = this.getNodeParameter('returnAll', i); let endpoint; - if (myLibrary === false) { + if (!myLibrary) { const userId = this.getNodeParameter('userId', i) as string; endpoint = `v1/users/${userId}/bookshelves`; } else { @@ -449,7 +449,7 @@ export class GoogleBooks implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); const myLibrary = this.getNodeParameter('myLibrary', i) as boolean; let endpoint; - if (myLibrary === false) { + if (!myLibrary) { const userId = this.getNodeParameter('userId', i) as string; endpoint = `v1/users/${userId}/bookshelves/${shelfId}/volumes`; } else { diff --git a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts index d01e625edb..1faf257922 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts @@ -40,7 +40,7 @@ export async function googleApiRequest( delete options.body; } //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'googleCalendarOAuth2Api', options); + return this.helpers.requestOAuth2.call(this, 'googleCalendarOAuth2Api', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -62,9 +62,9 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } 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 cf70f85fd3..257a227ea3 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts @@ -447,7 +447,7 @@ export class GoogleCalendar implements INodeType { const eventId = this.getNodeParameter('eventId', i) as string; const useDefaultReminders = this.getNodeParameter('useDefaultReminders', i) as boolean; const updateFields = this.getNodeParameter('updateFields', i); - const timezone = updateFields.timezone as string; + const updateTimezone = updateFields.timezone as string; if (updateFields.maxAttendees) { qs.maxAttendees = updateFields.maxAttendees as number; @@ -461,14 +461,14 @@ export class GoogleCalendar implements INodeType { const body: IEvent = {}; if (updateFields.start) { body.start = { - dateTime: moment.tz(updateFields.start, timezone).utc().format(), - timeZone: timezone, + dateTime: moment.tz(updateFields.start, updateTimezone).utc().format(), + timeZone: updateTimezone, }; } if (updateFields.end) { body.end = { - dateTime: moment.tz(updateFields.end, timezone).utc().format(), - timeZone: timezone, + dateTime: moment.tz(updateFields.end, updateTimezone).utc().format(), + timeZone: updateTimezone, }; } if (updateFields.attendees) { @@ -525,13 +525,13 @@ export class GoogleCalendar implements INodeType { } if (updateFields.allday && updateFields.start && updateFields.end) { body.start = { - date: timezone - ? moment.tz(updateFields.start, timezone).utc(true).format('YYYY-MM-DD') + date: updateTimezone + ? moment.tz(updateFields.start, updateTimezone).utc(true).format('YYYY-MM-DD') : moment.tz(updateFields.start, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), }; body.end = { - date: timezone - ? moment.tz(updateFields.end, timezone).utc(true).format('YYYY-MM-DD') + date: updateTimezone + ? moment.tz(updateFields.end, updateTimezone).utc(true).format('YYYY-MM-DD') : moment.tz(updateFields.end, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), }; } @@ -585,7 +585,7 @@ export class GoogleCalendar implements INodeType { ); returnData.push(...executionData); } catch (error) { - if (this.continueOnFail() !== true) { + if (!this.continueOnFail()) { throw error; } else { const executionErrorData = this.helpers.constructExecutionMetaData( diff --git a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts index 8970c9fd95..b7185629ed 100644 --- a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts @@ -97,14 +97,14 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } -export function getAccessToken( +export async function getAccessToken( this: | IExecuteFunctions | IExecuteSingleFunctions @@ -119,12 +119,12 @@ export function getAccessToken( const now = moment().unix(); credentials.email = credentials.email.trim(); - const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); + const privateKey = credentials.privateKey.replace(/\\n/g, '\n').trim(); const signature = jwt.sign( { - iss: credentials.email as string, - sub: credentials.delegatedEmail || (credentials.email as string), + iss: credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: `https://oauth2.googleapis.com/token`, iat: now, @@ -154,8 +154,7 @@ export function getAccessToken( json: true, }; - //@ts-ignore - return this.helpers.request(options); + return this.helpers.request!(options); } export function validateJSON(json: string | undefined): any { diff --git a/packages/nodes-base/nodes/Google/CloudStorage/BucketDescription.ts b/packages/nodes-base/nodes/Google/CloudStorage/BucketDescription.ts index 3d0946768f..585a9b3564 100644 --- a/packages/nodes-base/nodes/Google/CloudStorage/BucketDescription.ts +++ b/packages/nodes-base/nodes/Google/CloudStorage/BucketDescription.ts @@ -1,5 +1,10 @@ -import { IDataObject, IExecuteSingleFunctions, IHttpRequestOptions } from 'n8n-workflow'; -import { INodeExecutionData, INodeProperties } from 'n8n-workflow'; +import { + IDataObject, + IExecuteSingleFunctions, + IHttpRequestOptions, + INodeExecutionData, + INodeProperties, +} from 'n8n-workflow'; // Projection field controls the page limit maximum // When not returning all, return the max number for the current projection parameter @@ -185,6 +190,13 @@ export const bucketOperations: INodeProperties[] = [ let nextPageToken: string | undefined = undefined; const returnAll = this.getNodeParameter('returnAll') as boolean; + const extractBucketsList = (page: INodeExecutionData) => { + const buckets = page.json.items as IDataObject[]; + if (buckets) { + executions = executions.concat(buckets.map((bucket) => ({ json: bucket }))); + } + }; + do { requestOptions.options.qs.pageToken = nextPageToken; responseData = await this.makeRoutingRequest(requestOptions); @@ -194,12 +206,7 @@ export const bucketOperations: INodeProperties[] = [ nextPageToken = lastItem.nextPageToken as string | undefined; // Extract just the list of buckets from the page data - responseData.forEach((page) => { - const buckets = page.json.items as IDataObject[]; - if (buckets) { - executions = executions.concat(buckets.map((bucket) => ({ json: bucket }))); - } - }); + responseData.forEach(extractBucketsList); // If we don't return all, just return the first page } while (returnAll && nextPageToken); diff --git a/packages/nodes-base/nodes/Google/CloudStorage/ObjectDescription.ts b/packages/nodes-base/nodes/Google/CloudStorage/ObjectDescription.ts index f3bec51a27..dd6e4c2bee 100644 --- a/packages/nodes-base/nodes/Google/CloudStorage/ObjectDescription.ts +++ b/packages/nodes-base/nodes/Google/CloudStorage/ObjectDescription.ts @@ -1,6 +1,5 @@ import FormData from 'form-data'; -import { IDataObject, NodeOperationError } from 'n8n-workflow'; -import { INodeExecutionData, INodeProperties } from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeProperties, NodeOperationError } from 'n8n-workflow'; // Define these because we'll be using them in two separate places const metagenerationFilters: INodeProperties[] = [ @@ -307,6 +306,13 @@ export const objectOperations: INodeProperties[] = [ let nextPageToken: string | undefined = undefined; const returnAll = this.getNodeParameter('returnAll') as boolean; + const extractBucketsList = (page: INodeExecutionData) => { + const objects = page.json.items as IDataObject[]; + if (objects) { + executions = executions.concat(objects.map((object) => ({ json: object }))); + } + }; + do { requestOptions.options.qs.pageToken = nextPageToken; responseData = await this.makeRoutingRequest(requestOptions); @@ -316,12 +322,7 @@ export const objectOperations: INodeProperties[] = [ nextPageToken = lastItem.nextPageToken as string | undefined; // Extract just the list of buckets from the page data - responseData.forEach((page) => { - const objects = page.json.items as IDataObject[]; - if (objects) { - executions = executions.concat(objects.map((object) => ({ json: object }))); - } - }); + responseData.forEach(extractBucketsList); } while (returnAll && nextPageToken); // Return all execution responses as an array diff --git a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts index 25edfec9f5..a269b0282d 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts @@ -55,9 +55,9 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts b/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts index 310bd63224..ee55bce749 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts @@ -154,17 +154,17 @@ export class GoogleContacts implements INodeType { if (additionalFields.eventsUi) { const eventsValues = (additionalFields.eventsUi as IDataObject) .eventsValues as IDataObject[]; - for (let i = 0; i < eventsValues.length; i++) { - const [month, day, year] = moment(eventsValues[i].date as string) + for (let index = 0; index < eventsValues.length; index++) { + const [month, day, year] = moment(eventsValues[index].date as string) .format('MM/DD/YYYY') .split('/'); - eventsValues[i] = { + eventsValues[index] = { date: { day, month, year, }, - type: eventsValues[i].type, + type: eventsValues[index].type, }; } body.events = eventsValues; @@ -249,7 +249,7 @@ export class GoogleContacts implements INodeType { if (fields.includes('*')) { qs.personFields = allFields.join(','); } else { - qs.personFields = (fields as string[]).join(','); + qs.personFields = fields.join(','); } responseData = await googleApiRequest.call(this, 'GET', `/people/${contactId}`, {}, qs); @@ -265,7 +265,7 @@ export class GoogleContacts implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); const fields = this.getNodeParameter('fields', i) as string[]; - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); const rawData = this.getNodeParameter('rawData', i); const useQuery = this.getNodeParameter('useQuery', i) as boolean; @@ -282,7 +282,7 @@ export class GoogleContacts implements INodeType { if (fields.includes('*')) { qs.personFields = allFields.join(','); } else { - qs.personFields = (fields as string[]).join(','); + qs.personFields = fields.join(','); } if (useQuery) { @@ -317,8 +317,8 @@ export class GoogleContacts implements INodeType { responseData = cleanData(responseData); } - for (let i = 0; i < responseData.length; i++) { - responseData[i].contactId = responseData[i].resourceName.split('/')[1]; + for (let index = 0; index < responseData.length; index++) { + responseData[index].contactId = responseData[index].resourceName.split('/')[1]; } } //https://developers.google.com/people/api/rest/v1/people/updateContact @@ -350,7 +350,7 @@ export class GoogleContacts implements INodeType { if (fields.includes('*')) { qs.personFields = allFields.join(','); } else { - qs.personFields = (fields as string[]).join(','); + qs.personFields = fields.join(','); } const body: IDataObject = { @@ -414,17 +414,17 @@ export class GoogleContacts implements INodeType { if (updateFields.eventsUi) { const eventsValues = (updateFields.eventsUi as IDataObject) .eventsValues as IDataObject[]; - for (let i = 0; i < eventsValues.length; i++) { - const [month, day, year] = moment(eventsValues[i].date as string) + for (let index = 0; index < eventsValues.length; index++) { + const [month, day, year] = moment(eventsValues[index].date as string) .format('MM/DD/YYYY') .split('/'); - eventsValues[i] = { + eventsValues[index] = { date: { day, month, year, }, - type: eventsValues[i].type, + type: eventsValues[index].type, }; } body.events = eventsValues; diff --git a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts index f677c6e94a..07d0978007 100644 --- a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts @@ -81,14 +81,14 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } -function getAccessToken( +async function getAccessToken( this: IExecuteFunctions | ILoadOptionsFunctions, credentials: IGoogleAuthCredentials, ): Promise { @@ -103,22 +103,22 @@ function getAccessToken( const now = moment().unix(); credentials.email = credentials.email.trim(); - const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); + const privateKey = credentials.privateKey.replace(/\\n/g, '\n').trim(); const signature = jwt.sign( { - iss: credentials.email as string, - sub: credentials.delegatedEmail || (credentials.email as string), + iss: credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: `https://oauth2.googleapis.com/token`, iat: now, exp: now + 3600, }, - privateKey as string, + privateKey, { algorithm: 'RS256', header: { - kid: privateKey as string, + kid: privateKey, typ: 'JWT', alg: 'RS256', }, diff --git a/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts b/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts index 5462a4c8f8..8d96d2ab48 100644 --- a/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts +++ b/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts @@ -116,6 +116,7 @@ export class GoogleDocs implements INodeType { ...documentFields, ], }; + methods = { loadOptions: { // Get all the drives to display them to user so that he can @@ -195,6 +196,7 @@ export class GoogleDocs implements INodeType { }, }, }; + async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: INodeExecutionData[] = []; @@ -241,11 +243,11 @@ export class GoogleDocs implements INodeType { if (simple) { const content = (responseData.body.content as IDataObject[]) .reduce((arr: string[], contentItem) => { - if (contentItem && contentItem.paragraph) { + if (contentItem?.paragraph) { const texts = ( (contentItem.paragraph as IDataObject).elements as IDataObject[] ).map((element) => { - if (element && element.textRun) { + if (element?.textRun) { return (element.textRun as IDataObject).content as string; } }) as string[]; @@ -491,7 +493,7 @@ export class GoogleDocs implements INodeType { body, ); - if (simple === true) { + if (simple) { if (Object.keys(responseData.replies[0]).length !== 0) { const key = Object.keys(responseData.replies[0])[0]; responseData = responseData.replies[0][key]; diff --git a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts index 12f278c0af..e70220f84d 100644 --- a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts @@ -58,10 +58,10 @@ export async function googleApiRequest( ); options.headers!.Authorization = `Bearer ${access_token}`; - return await this.helpers.request!(options); + return this.helpers.request!(options); } else { //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'googleDriveOAuth2Api', options); + return this.helpers.requestOAuth2.call(this, 'googleDriveOAuth2Api', options); } } catch (error) { if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') { @@ -90,12 +90,12 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } -function getAccessToken( +async function getAccessToken( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, credentials: IGoogleAuthCredentials, ): Promise { @@ -110,22 +110,22 @@ function getAccessToken( const now = moment().unix(); credentials.email = credentials.email.trim(); - const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); + const privateKey = credentials.privateKey.replace(/\\n/g, '\n').trim(); const signature = jwt.sign( { - iss: credentials.email as string, - sub: credentials.delegatedEmail || (credentials.email as string), + iss: credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: `https://oauth2.googleapis.com/token`, iat: now, exp: now + 3600, }, - privateKey as string, + privateKey, { algorithm: 'RS256', header: { - kid: privateKey as string, + kid: privateKey, typ: 'JWT', alg: 'RS256', }, diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts index da4fe5c7ac..214d782f7b 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts @@ -2044,7 +2044,7 @@ export class GoogleDrive implements INodeType { query.push(`mimeType != 'application/vnd.google-apps.folder'`); const res = await googleApiRequest.call(this, 'GET', '/drive/v3/files', undefined, { q: query.join(' and '), - pageToken: paginationToken as string | undefined, + pageToken: paginationToken, fields: 'nextPageToken,files(id,name,mimeType,webViewLink)', orderBy: 'name_natural', }); @@ -2069,7 +2069,7 @@ export class GoogleDrive implements INodeType { query.push(`mimeType = 'application/vnd.google-apps.folder'`); const res = await googleApiRequest.call(this, 'GET', '/drive/v3/files', undefined, { q: query.join(' and '), - pageToken: paginationToken as string | undefined, + pageToken: paginationToken, fields: 'nextPageToken,files(id,name,mimeType,webViewLink)', orderBy: 'name_natural', }); @@ -2089,7 +2089,7 @@ export class GoogleDrive implements INodeType { ): Promise { const res = await googleApiRequest.call(this, 'GET', '/drive/v3/drives', undefined, { q: filter ? `name contains '${filter.replace("'", "\\'")}'` : undefined, - pageToken: paginationToken as string | undefined, + pageToken: paginationToken, }); return { results: res.drives.map((i: GoogleDriveDriveItem) => ({ @@ -2111,10 +2111,10 @@ export class GoogleDrive implements INodeType { for (let i = 0; i < items.length; i++) { try { - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); let queryFields = 'id, name'; - if (options && options.fields) { + if (options?.fields) { const fields = options.fields as string[]; if (fields.includes('*')) { queryFields = '*'; @@ -2206,7 +2206,7 @@ export class GoogleDrive implements INodeType { Object.assign(qs, options); - if (returnAll === true) { + if (returnAll) { response = await googleApiRequestAllItems.call( this, 'drives', @@ -2303,7 +2303,7 @@ export class GoogleDrive implements INodeType { const fileId = this.getNodeParameter('fileId', i, undefined, { extractValue: true, }) as string; - const options = this.getNodeParameter('options', i); + const downloadOptions = this.getNodeParameter('options', i); const requestOptions = { resolveWithFullResponse: true, @@ -2376,8 +2376,8 @@ export class GoogleDrive implements INodeType { mimeType = response.headers['content-type']; } - if (options.fileName) { - fileName = options.fileName as string; + if (downloadOptions.fileName) { + fileName = downloadOptions.fileName as string; } const newItem: INodeExecutionData = { @@ -2435,7 +2435,7 @@ export class GoogleDrive implements INodeType { let queryString = ''; const useQueryString = this.getNodeParameter('useQueryString', i) as boolean; - if (useQueryString === true) { + if (useQueryString) { // Use the user defined query string queryString = this.getNodeParameter('queryString', i) as string; } else { @@ -2445,13 +2445,13 @@ export class GoogleDrive implements INodeType { const queryFilterFields: string[] = []; if (queryFilters.name) { (queryFilters.name as IDataObject[]).forEach((nameFilter) => { - let operation = nameFilter.operation; - if (operation === 'is') { - operation = '='; - } else if (operation === 'isNot') { - operation = '!='; + let filterOperation = nameFilter.operation; + if (filterOperation === 'is') { + filterOperation = '='; + } else if (filterOperation === 'isNot') { + filterOperation = '!='; } - queryFilterFields.push(`name ${operation} '${nameFilter.value}'`); + queryFilterFields.push(`name ${filterOperation} '${nameFilter.value}'`); }); queryString += queryFilterFields.join(' or '); @@ -2491,7 +2491,7 @@ export class GoogleDrive implements INodeType { const response = await googleApiRequest.call(this, 'GET', `/drive/v3/files`, {}, qs); - const files = response!.files; + const files = response.files; const version = this.getNode().typeVersion; @@ -2514,7 +2514,7 @@ export class GoogleDrive implements INodeType { let mimeType = 'text/plain'; let body; let originalFilename: string | undefined; - if (this.getNodeParameter('binaryData', i) === true) { + if (this.getNodeParameter('binaryData', i)) { // Is binary file to upload const item = items[i]; @@ -2625,7 +2625,7 @@ export class GoogleDrive implements INodeType { qs, ); - if (resolveData === true) { + if (resolveData) { response = await googleApiRequest.call( this, 'GET', @@ -2648,7 +2648,7 @@ export class GoogleDrive implements INodeType { const id = this.getNodeParameter('fileId', i, undefined, { extractValue: true, }) as string; - const updateFields = this.getNodeParameter('updateFields', i, {}) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i, {}); const qs: IDataObject = { supportsAllDrives: true, @@ -2751,7 +2751,7 @@ export class GoogleDrive implements INodeType { const permissions = this.getNodeParameter('permissionsUi', i) as IDataObject; - const options = this.getNodeParameter('options', i); + const shareOption = this.getNodeParameter('options', i); const body: IDataObject = {}; @@ -2763,7 +2763,7 @@ export class GoogleDrive implements INodeType { Object.assign(body, permissions.permissionsValues); } - Object.assign(qs, options); + Object.assign(qs, shareOption); const response = await googleApiRequest.call( this, diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts index 877ec9874a..c105b925d1 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts @@ -61,9 +61,9 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } 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 bee639d432..7b5c67c496 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts @@ -116,7 +116,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { responseData = responseData.map((element: { found: { id: string; name: string } }) => { if (element.found) { - element.found.id = (element.found.name as string).split('/').pop() as string; + element.found.id = element.found.name.split('/').pop() as string; } return element; }); @@ -148,9 +148,9 @@ export class GoogleFirebaseCloudFirestore implements INodeType { const document = { fields: {} }; columnList.map((column) => { // @ts-ignore - if (item['json'][column]) { + if (item.json[column]) { // @ts-ignore - document.fields[column] = jsonToDocument(item['json'][column]); + document.fields[column] = jsonToDocument(item.json[column]); } else { // @ts-ignore document.fields[column] = jsonToDocument(null); @@ -209,9 +209,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { }); if (simple) { - responseData = responseData.map((element: IDataObject) => - fullDocumentToJson(element as IDataObject), - ); + responseData = responseData.map((element: IDataObject) => fullDocumentToJson(element)); } const executionData = this.helpers.constructExecutionMetaData( @@ -250,15 +248,15 @@ export class GoogleFirebaseCloudFirestore implements INodeType { const collection = this.getNodeParameter('collection', i) as string; const updateKey = this.getNodeParameter('updateKey', i) as string; // @ts-ignore - const documentId = item['json'][updateKey] as string; + const documentId = item.json[updateKey] as string; const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map((column) => column.trim()) as string[]; + const columnList = columns.split(',').map((column) => column.trim()); const document = {}; columnList.map((column) => { // @ts-ignore - if (item['json'].hasOwnProperty(column)) { + if (item.json.hasOwnProperty(column)) { // @ts-ignore - document[column] = jsonToDocument(item['json'][column]); + document[column] = jsonToDocument(item.json[column]); } else { // @ts-ignore document[column] = jsonToDocument(null); @@ -286,7 +284,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { ); for (let i = 0; i < writeResults.length; i++) { - writeResults[i]['status'] = status[i]; + writeResults[i].status = status[i]; Object.assign(writeResults[i], items[i].json); const executionData = this.helpers.constructExecutionMetaData( @@ -345,9 +343,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { responseData = responseData.map( (element: { document: { id: string; name: string } }) => { if (element.document) { - element.document.id = (element.document.name as string) - .split('/') - .pop() as string; + element.document.id = element.document.name.split('/').pop() as string; } return element; }, diff --git a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts index 1e139d4390..e4996c8b06 100644 --- a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts @@ -75,9 +75,9 @@ export async function googleApiRequestAllItems( {}, uri, ); - qs.pageToken = responseData['nextPageToken']; + qs.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[resource]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts index e2d9337fcf..d3ab4f0475 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts @@ -54,9 +54,9 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } 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 e0acf0839d..0319df5678 100644 --- a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts @@ -83,7 +83,7 @@ export async function googleApiRequest( const { access_token } = await getAccessToken.call(this, credentials); - (options.headers as IDataObject)['Authorization'] = `Bearer ${access_token}`; + (options.headers as IDataObject).Authorization = `Bearer ${access_token}`; } const response = await this.helpers.requestWithAuthentication.call( @@ -100,13 +100,13 @@ export async function googleApiRequest( if (error.httpCode === '400') { if (error.cause && ((error.cause.message as string) || '').includes('Invalid id value')) { const resource = this.getNodeParameter('resource', 0) as string; - const options = { + const errorOptions = { message: `Invalid ${resource} ID`, description: `${ resource.charAt(0).toUpperCase() + resource.slice(1) } IDs should look something like this: 182b676d244938bd`, }; - throw new NodeApiError(this.getNode(), error, options); + throw new NodeApiError(this.getNode(), error, errorOptions); } } @@ -115,41 +115,41 @@ export async function googleApiRequest( if (resource === 'label') { resource = 'label ID'; } - const options = { + const errorOptions = { message: `${resource.charAt(0).toUpperCase() + resource.slice(1)} not found`, description: '', }; - throw new NodeApiError(this.getNode(), error, options); + throw new NodeApiError(this.getNode(), error, errorOptions); } if (error.httpCode === '409') { const resource = this.getNodeParameter('resource', 0) as string; if (resource === 'label') { - const options = { + const errorOptions = { message: `Label name exists already`, description: '', }; - throw new NodeApiError(this.getNode(), error, options); + throw new NodeApiError(this.getNode(), error, errorOptions); } } if (error.code === 'EAUTH') { - const options = { + const errorOptions = { message: error?.body?.error_description || 'Authorization error', description: (error as Error).message, }; - throw new NodeApiError(this.getNode(), error, options); + throw new NodeApiError(this.getNode(), error, errorOptions); } if ( ((error.message as string) || '').includes('Bad request - please check your parameters') && error.description ) { - const options = { + const errorOptions = { message: error.description, description: ``, }; - throw new NodeApiError(this.getNode(), error, options); + throw new NodeApiError(this.getNode(), error, errorOptions); } throw new NodeApiError(this.getNode(), error, { @@ -224,8 +224,6 @@ export async function parseRawEmail( export async function encodeEmail(email: IEmail) { // https://nodemailer.com/extras/mailcomposer/#e-mail-message-fields - let mailBody: Buffer; - const mailOptions = { from: email.from, to: email.to, @@ -265,7 +263,7 @@ export async function encodeEmail(email: IEmail) { //https://nodemailer.com/extras/mailcomposer/#bcc mail.keepBcc = true; - mailBody = await mail.build(); + const mailBody = await mail.build(); return mailBody.toString('base64').replace(/\+/g, '-').replace(/\//g, '_'); } @@ -286,9 +284,9 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } @@ -301,7 +299,7 @@ export function extractEmail(s: string) { return s; } -function getAccessToken( +async function getAccessToken( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, credentials: ICredentialDataDecryptedObject, ): Promise { @@ -323,8 +321,8 @@ function getAccessToken( const signature = jwt.sign( { - iss: credentials.email as string, - sub: credentials.delegatedEmail || (credentials.email as string), + iss: credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: `https://oauth2.googleapis.com/token`, iat: now, @@ -354,8 +352,7 @@ function getAccessToken( json: true, }; - //@ts-ignore - return this.helpers.request(options); + return this.helpers.request!(options); } export function prepareQuery( @@ -503,7 +500,7 @@ export async function prepareEmailAttachments( itemIndex: number, ) { const attachmentsList: IDataObject[] = []; - const attachments = (options as IDataObject).attachmentsBinary as IDataObject[]; + const attachments = options.attachmentsBinary as IDataObject[]; if (attachments && !isEmpty(attachments)) { for (const { property } of attachments) { @@ -540,27 +537,24 @@ export async function prepareEmailAttachments( export function unescapeSnippets(items: INodeExecutionData[]) { const result = items.map((item) => { - const snippet = (item.json as IDataObject).snippet as string; + const snippet = item.json.snippet as string; if (snippet) { - (item.json as IDataObject).snippet = snippet.replace( - /&|<|>|'|"/g, - (match) => { - switch (match) { - case '&': - return '&'; - case '<': - return '<'; - case '>': - return '>'; - case ''': - return "'"; - case '"': - return '"'; - default: - return match; - } - }, - ); + item.json.snippet = snippet.replace(/&|<|>|'|"/g, (match) => { + switch (match) { + case '&': + return '&'; + case '<': + return '<'; + case '>': + return '>'; + case ''': + return "'"; + case '"': + return '"'; + default: + return match; + } + }); } return item; }); @@ -624,6 +618,15 @@ export async function replayToEmail( const replyToSenderOnly = options.replyToSenderOnly === undefined ? false : (options.replyToSenderOnly as boolean); + const prepareEmailString = (email: string) => { + if (email.includes(emailAddress)) return; + if (email.includes('<') && email.includes('>')) { + to += `${email}, `; + } else { + to += `<${email}>, `; + } + }; + for (const header of payload.headers as IDataObject[]) { if (((header.name as string) || '').toLowerCase() === 'from') { const from = header.value as string; @@ -636,14 +639,7 @@ export async function replayToEmail( if (((header.name as string) || '').toLowerCase() === 'to' && !replyToSenderOnly) { const toEmails = header.value as string; - toEmails.split(',').forEach((email: string) => { - if (email.includes(emailAddress)) return; - if (email.includes('<') && email.includes('>')) { - to += `${email}, `; - } else { - to += `<${email}>, `; - } - }); + toEmails.split(',').forEach(prepareEmailString); } } @@ -669,7 +665,7 @@ export async function replayToEmail( threadId, }; - return await googleApiRequest.call(this, 'POST', '/gmail/v1/users/me/messages/send', body, qs); + return googleApiRequest.call(this, 'POST', '/gmail/v1/users/me/messages/send', body, qs); } export async function simplifyOutput( @@ -681,7 +677,7 @@ export async function simplifyOutput( id, name, })); - return ((data as IDataObject[]) || []).map((item) => { + return (data || []).map((item) => { if (item.labelIds) { item.labels = labels.filter((label) => (item.labelIds as string[]).includes(label.id as string), 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 8b8ff1cb7d..168425920d 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts @@ -351,7 +351,7 @@ export class GmailV1 implements INodeType { attachments: attachmentsList, }; - if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) { + if (this.getNodeParameter('includeHtml', i, false) as boolean) { email.htmlBody = this.getNodeParameter('htmlMessage', i) as string; } @@ -465,7 +465,7 @@ export class GmailV1 implements INodeType { attachments: attachmentsList, }; - if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) { + if (this.getNodeParameter('includeHtml', i, false) as boolean) { email.htmlBody = this.getNodeParameter('htmlMessage', i) as string; } @@ -566,11 +566,11 @@ export class GmailV1 implements INodeType { qs.format = format; } - for (let i = 0; i < responseData.length; i++) { - responseData[i] = await googleApiRequest.call( + for (let index = 0; index < responseData.length; index++) { + responseData[index] = await googleApiRequest.call( this, 'GET', - `/gmail/v1/users/me/messages/${responseData[i].id}`, + `/gmail/v1/users/me/messages/${responseData[index].id}`, body, qs, ); @@ -579,9 +579,9 @@ export class GmailV1 implements INodeType { const dataPropertyNameDownload = (additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; - responseData[i] = await parseRawEmail.call( + responseData[index] = await parseRawEmail.call( this, - responseData[i], + responseData[index], dataPropertyNameDownload, ); } @@ -686,7 +686,7 @@ export class GmailV1 implements INodeType { attachments: attachmentsList, }; - if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) { + if (this.getNodeParameter('includeHtml', i, false) as boolean) { email.htmlBody = this.getNodeParameter('htmlMessage', i) as string; } @@ -794,11 +794,11 @@ export class GmailV1 implements INodeType { qs.format = format; } - for (let i = 0; i < responseData.length; i++) { - responseData[i] = await googleApiRequest.call( + for (let index = 0; index < responseData.length; index++) { + responseData[index] = await googleApiRequest.call( this, 'GET', - `/gmail/v1/users/me/drafts/${responseData[i].id}`, + `/gmail/v1/users/me/drafts/${responseData[index].id}`, body, qs, ); @@ -806,16 +806,16 @@ export class GmailV1 implements INodeType { if (format === 'resolved') { const dataPropertyNameDownload = (additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; - const id = responseData[i].id; - responseData[i] = await parseRawEmail.call( + const id = responseData[index].id; + responseData[index] = await parseRawEmail.call( this, - responseData[i].message, + responseData[index].message, dataPropertyNameDownload, ); // Add the draft-id - responseData[i].json.messageId = responseData[i].json.id; - responseData[i].json.id = id; + responseData[index].json.messageId = responseData[index].json.id; + responseData[index].json.id = id; } } } 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 67027e04f8..30102df1e1 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts @@ -349,7 +349,7 @@ export class GmailV2 implements INodeType { const endpoint = `/gmail/v1/users/me/messages/${id}`; const qs: IDataObject = {}; - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); const simple = this.getNodeParameter('simple', i) as boolean; if (simple) { @@ -380,8 +380,8 @@ export class GmailV2 implements INodeType { } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - const options = this.getNodeParameter('options', i, {}) as IDataObject; - const filters = this.getNodeParameter('filters', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); + const filters = this.getNodeParameter('filters', i, {}); const qs: IDataObject = {}; Object.assign(qs, prepareQuery.call(this, filters), options); @@ -419,11 +419,11 @@ export class GmailV2 implements INodeType { qs.format = 'raw'; } - for (let i = 0; i < responseData.length; i++) { - responseData[i] = await googleApiRequest.call( + for (let index = 0; index < responseData.length; index++) { + responseData[index] = await googleApiRequest.call( this, 'GET', - `/gmail/v1/users/me/messages/${responseData[i].id}`, + `/gmail/v1/users/me/messages/${responseData[index].id}`, {}, qs, ); @@ -432,9 +432,9 @@ export class GmailV2 implements INodeType { const dataPropertyNameDownload = (options.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; - responseData[i] = await parseRawEmail.call( + responseData[index] = await parseRawEmail.call( this, - responseData[i], + responseData[index], dataPropertyNameDownload, ); } @@ -578,12 +578,10 @@ export class GmailV2 implements INodeType { responseData = await googleApiRequest.call(this, 'GET', endpoint, {}, qs); - let nodeExecutionData: INodeExecutionData; - const dataPropertyNameDownload = (options.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; - nodeExecutionData = await parseRawEmail.call( + const nodeExecutionData = await parseRawEmail.call( this, responseData.message, dataPropertyNameDownload, @@ -637,27 +635,27 @@ export class GmailV2 implements INodeType { qs.format = 'raw'; - for (let i = 0; i < responseData.length; i++) { - responseData[i] = await googleApiRequest.call( + for (let index = 0; index < responseData.length; index++) { + responseData[index] = await googleApiRequest.call( this, 'GET', - `/gmail/v1/users/me/drafts/${responseData[i].id}`, + `/gmail/v1/users/me/drafts/${responseData[index].id}`, {}, qs, ); const dataPropertyNameDownload = (options.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; - const id = responseData[i].id; - responseData[i] = await parseRawEmail.call( + const id = responseData[index].id; + responseData[index] = await parseRawEmail.call( this, - responseData[i].message, + responseData[index].message, dataPropertyNameDownload, ); // Add the draft-id - responseData[i].json.messageId = responseData[i].json.id; - responseData[i].json.id = id; + responseData[index].json.messageId = responseData[index].json.id; + responseData[index].json.id = id; } } } diff --git a/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts index 27abaa12c4..37b223d561 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts @@ -88,14 +88,14 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } -export function getAccessToken( +export async function getAccessToken( this: | IExecuteFunctions | IExecuteSingleFunctions @@ -114,12 +114,12 @@ export function getAccessToken( const now = moment().unix(); credentials.email = credentials.email.trim(); - const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); + const privateKey = credentials.privateKey.replace(/\\n/g, '\n').trim(); const signature = jwt.sign( { - iss: credentials.email as string, - sub: credentials.delegatedEmail || (credentials.email as string), + iss: credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: `https://oauth2.googleapis.com/token`, iat: now, @@ -149,8 +149,7 @@ export function getAccessToken( json: true, }; - //@ts-ignore - return this.helpers.request(options); + return this.helpers.request!(options); } // Hex to RGB diff --git a/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheet.ts b/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheet.ts index b57aae3995..692ac69416 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheet.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheet.ts @@ -45,6 +45,7 @@ export type ValueRenderOption = 'FORMATTED_VALUE' | 'FORMULA' | 'UNFORMATTED_VAL export class GoogleSheet { id: string; + executeFunctions: IExecuteFunctions | ILoadOptionsFunctions; constructor( @@ -310,14 +311,14 @@ export class GoogleSheet { upsert = false, ): Promise { // Get current data in Google Sheet - let rangeStart: string, rangeEnd: string, rangeFull: string; + let rangeFull: string; let sheet: string | undefined = undefined; if (range.includes('!')) { [sheet, rangeFull] = range.split('!'); } else { rangeFull = range; } - [rangeStart, rangeEnd] = rangeFull.split(':'); + const [rangeStart, rangeEnd] = rangeFull.split(':'); const rangeStartSplit = rangeStart.match(/([a-zA-Z]{1,10})([0-9]{0,10})/); const rangeEndSplit = rangeEnd.match(/([a-zA-Z]{1,10})([0-9]{0,10})/); @@ -411,7 +412,7 @@ export class GoogleSheet { } // Item does have the key so check if it exists in Sheet - itemKeyIndex = keyColumnIndexLookup.indexOf(itemKey as string); + itemKeyIndex = keyColumnIndexLookup.indexOf(itemKey); if (itemKeyIndex === -1) { // Key does not exist in the Sheet so it can not be updated so skip it or append it if upsert true if (upsert) { @@ -547,12 +548,11 @@ export class GoogleSheet { keyRowIndex: number, usePathForKeyRow: boolean, ): Promise { - let startColumn, endColumn; let sheet: string | undefined = undefined; if (range.includes('!')) { [sheet, range] = range.split('!'); } - [startColumn, endColumn] = range.split(':'); + const [startColumn, endColumn] = range.split(':'); let getRange = `${startColumn}${keyRowIndex + 1}:${endColumn}${keyRowIndex + 1}`; @@ -580,7 +580,7 @@ export class GoogleSheet { const value = get(item, key) as string; if (usePathForKeyRow && value !== undefined && value !== null) { //match by key path - rowData.push(value!.toString()); + rowData.push(value.toString()); } else if ( !usePathForKeyRow && item.hasOwnProperty(key) && 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 dc5bf7e260..efc1769ead 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts @@ -56,14 +56,14 @@ export class GoogleSheetsV1 implements INodeType { } const returnData: INodePropertyOptions[] = []; - for (const sheet of responseData.sheets!) { - if (sheet.properties!.sheetType !== 'GRID') { + for (const entry of responseData.sheets!) { + if (entry.properties!.sheetType !== 'GRID') { continue; } returnData.push({ - name: sheet.properties!.title as string, - value: sheet.properties!.sheetId as unknown as string, + name: entry.properties!.title as string, + value: entry.properties!.sheetId as unknown as string, }); } @@ -115,7 +115,7 @@ export class GoogleSheetsV1 implements INodeType { range = this.getNodeParameter('range', 0) as string; } - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const valueInputMode = (options.valueInputMode || 'RAW') as ValueInputOption; const valueRenderMode = (options.valueRenderMode || 'UNFORMATTED_VALUE') as ValueRenderOption; @@ -148,7 +148,7 @@ export class GoogleSheetsV1 implements INodeType { // TODO: Should add this data somewhere // TODO: Should have something like add metadata which does not get passed through - return this.prepareOutputData(items); + return await this.prepareOutputData(items); } catch (error) { if (this.continueOnFail()) { return this.prepareOutputData([{ json: { error: error.message } }]); @@ -163,7 +163,7 @@ export class GoogleSheetsV1 implements INodeType { await sheet.clearData(sheet.encodeRange(range)); const items = this.getInputData(); - return this.prepareOutputData(items); + return await this.prepareOutputData(items); } catch (error) { if (this.continueOnFail()) { return this.prepareOutputData([{ json: { error: error.message } }]); @@ -176,13 +176,13 @@ export class GoogleSheetsV1 implements INodeType { let responseData; for (let i = 0; i < this.getInputData().length; i++) { try { - const spreadsheetId = this.getNodeParameter('sheetId', i) as string; - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const sheetId = this.getNodeParameter('sheetId', i) as string; + const iterationOptions = this.getNodeParameter('options', i, {}); const simple = this.getNodeParameter('simple', 0) as boolean; - const properties = { ...options }; + const properties = { ...iterationOptions }; - if (options.tabColor) { - const { red, green, blue } = hexToRgb(options.tabColor as string)!; + if (iterationOptions.tabColor) { + const { red, green, blue } = hexToRgb(iterationOptions.tabColor as string)!; properties.tabColor = { red: red / 255, green: green / 255, blue: blue / 255 }; } @@ -197,11 +197,11 @@ export class GoogleSheetsV1 implements INodeType { responseData = await googleApiRequest.call( this, 'POST', - `/v4/spreadsheets/${spreadsheetId}:batchUpdate`, + `/v4/spreadsheets/${sheetId}:batchUpdate`, { requests }, ); - if (simple === true) { + if (simple) { Object.assign(responseData, responseData.replies[0].addSheet.properties); delete responseData.replies; } @@ -232,16 +232,16 @@ export class GoogleSheetsV1 implements INodeType { for (const propertyName of Object.keys(deletePropertyToDimensions)) { if (toDelete[propertyName] !== undefined) { - toDelete[propertyName]!.forEach((range) => { + toDelete[propertyName]!.forEach((entry) => { requests.push({ deleteDimension: { range: { - sheetId: range.sheetId, + sheetId: entry.sheetId, dimension: deletePropertyToDimensions[propertyName] as string, - startIndex: range.startIndex, + startIndex: entry.startIndex, endIndex: - parseInt(range.startIndex.toString(), 10) + - parseInt(range.amount.toString(), 10), + parseInt(entry.startIndex.toString(), 10) + + parseInt(entry.amount.toString(), 10), }, }, }); @@ -252,7 +252,7 @@ export class GoogleSheetsV1 implements INodeType { const _data = await sheet.spreadsheetBatchUpdate(requests); const items = this.getInputData(); - return this.prepareOutputData(items); + return await this.prepareOutputData(items); } catch (error) { if (this.continueOnFail()) { return this.prepareOutputData([{ json: { error: error.message } }]); @@ -314,14 +314,14 @@ export class GoogleSheetsV1 implements INodeType { // read // ---------------------------------- try { - const rawData = this.getNodeParameter('rawData', 0) as boolean; + const rawData = this.getNodeParameter('rawData', 0); const sheetData = await sheet.getData(sheet.encodeRange(range), valueRenderMode); let returnData: IDataObject[]; if (!sheetData) { returnData = []; - } else if (rawData === true) { + } else if (rawData) { const dataProperty = this.getNodeParameter('dataProperty', 0) as string; returnData = [ { @@ -352,13 +352,13 @@ export class GoogleSheetsV1 implements INodeType { let responseData; for (let i = 0; i < this.getInputData().length; i++) { try { - const sheetId = this.getNodeParameter('id', i) as string; - const spreadsheetId = this.getNodeParameter('sheetId', i) as string; + const id = this.getNodeParameter('id', i) as string; + const sheetId = this.getNodeParameter('sheetId', i) as string; const requests = [ { deleteSheet: { - sheetId, + sheetId: id, }, }, ]; @@ -366,7 +366,7 @@ export class GoogleSheetsV1 implements INodeType { responseData = await googleApiRequest.call( this, 'POST', - `/v4/spreadsheets/${spreadsheetId}:batchUpdate`, + `/v4/spreadsheets/${sheetId}:batchUpdate`, { requests }, ); delete responseData.replies; @@ -387,11 +387,11 @@ export class GoogleSheetsV1 implements INodeType { // ---------------------------------- const upsert = operation === 'upsert' ? true : false; try { - const rawData = this.getNodeParameter('rawData', 0) as boolean; + const rawData = this.getNodeParameter('rawData', 0); const items = this.getInputData(); - if (rawData === true) { + if (rawData) { const dataProperty = this.getNodeParameter('dataProperty', 0) as string; const updateData: ISheetUpdateData[] = []; @@ -427,7 +427,7 @@ export class GoogleSheetsV1 implements INodeType { // TODO: Should add this data somewhere // TODO: Should have something like add metadata which does not get passed through - return this.prepareOutputData(items); + return await this.prepareOutputData(items); } catch (error) { if (this.continueOnFail()) { return this.prepareOutputData([{ json: { error: error.message } }]); @@ -462,7 +462,7 @@ export class GoogleSheetsV1 implements INodeType { sheets: [] as IDataObject[], }; - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); if (Object.keys(sheetsUi).length) { const data = []; @@ -476,10 +476,10 @@ export class GoogleSheetsV1 implements INodeType { body.sheets = data; } - body.properties!.autoRecalc = options.autoRecalc + body.properties.autoRecalc = options.autoRecalc ? (options.autoRecalc as string) : undefined; - body.properties!.locale = options.locale ? (options.locale as string) : undefined; + body.properties.locale = options.locale ? (options.locale as string) : undefined; responseData = await googleApiRequest.call(this, 'POST', `/v4/spreadsheets`, body); diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/GoogleSheetsV2.node.ts b/packages/nodes-base/nodes/Google/Sheet/v2/GoogleSheetsV2.node.ts index 89289d48ef..b0b40e300a 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/GoogleSheetsV2.node.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/GoogleSheetsV2.node.ts @@ -13,6 +13,7 @@ export class GoogleSheetsV2 implements INodeType { ...versionDescription, }; } + methods = { loadOptions, credentialTest, @@ -20,6 +21,6 @@ export class GoogleSheetsV2 implements INodeType { }; async execute(this: IExecuteFunctions) { - return await router.call(this); + return router.call(this); } } diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts index 5c6b8c6f19..bce02f26cd 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts @@ -161,11 +161,11 @@ export async function execute( if (!items.length || dataMode === 'nothing') return []; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; - const locationDefine = ((options.locationDefine as IDataObject) || {}).values as IDataObject; + const options = this.getNodeParameter('options', 0, {}); + const locationDefine = (options.locationDefine as IDataObject)?.values as IDataObject; let headerRow = 1; - if (locationDefine && locationDefine.headerRow) { + if (locationDefine?.headerRow) { headerRow = locationDefine.headerRow as number; } diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts index d877714718..fce8b06e59 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts @@ -1,8 +1,12 @@ import { IExecuteFunctions } from 'n8n-core'; -import { ISheetUpdateData, SheetProperties } from '../../helpers/GoogleSheets.types'; +import { + ISheetUpdateData, + SheetProperties, + ValueInputOption, + ValueRenderOption, +} from '../../helpers/GoogleSheets.types'; import { IDataObject, INodeExecutionData, NodeOperationError } from 'n8n-workflow'; import { GoogleSheet } from '../../helpers/GoogleSheet'; -import { ValueInputOption, ValueRenderOption } from '../../helpers/GoogleSheets.types'; import { untilSheetSelected } from '../../helpers/GoogleSheets.utils'; import { cellFormat, handlingExtraData, locationDefine } from './commonDescription'; @@ -166,21 +170,21 @@ export async function execute( const valueInputMode = this.getNodeParameter('options.cellFormat', 0, 'RAW') as ValueInputOption; const range = `${sheetName}!A:Z`; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const valueRenderMode = (options.valueRenderMode || 'UNFORMATTED_VALUE') as ValueRenderOption; - const locationDefine = ((options.locationDefine as IDataObject) || {}).values as IDataObject; + const locationDefineOption = (options.locationDefine as IDataObject)?.values as IDataObject; let headerRow = 0; let firstDataRow = 1; - if (locationDefine) { - if (locationDefine.headerRow) { - headerRow = parseInt(locationDefine.headerRow as string, 10) - 1; + if (locationDefineOption) { + if (locationDefineOption.headerRow) { + headerRow = parseInt(locationDefineOption.headerRow as string, 10) - 1; } - if (locationDefine.firstDataRow) { - firstDataRow = parseInt(locationDefine.firstDataRow as string, 10) - 1; + if (locationDefineOption.firstDataRow) { + firstDataRow = parseInt(locationDefineOption.firstDataRow as string, 10) - 1; } } @@ -223,13 +227,13 @@ export async function execute( const data: IDataObject[] = []; if (dataMode === 'autoMapInputData') { - const handlingExtraData = (options.handlingExtraData as string) || 'insertInNewColumn'; - if (handlingExtraData === 'ignoreIt') { + const handlingExtraDataOption = (options.handlingExtraData as string) || 'insertInNewColumn'; + if (handlingExtraDataOption === 'ignoreIt') { data.push(items[i].json); } - if (handlingExtraData === 'error') { + if (handlingExtraDataOption === 'error') { Object.keys(items[i].json).forEach((key) => { - if (columnNames.includes(key) === false) { + if (!columnNames.includes(key)) { throw new NodeOperationError(this.getNode(), `Unexpected fields in node input`, { itemIndex: i, description: `The input field '${key}' doesn't match any column in the Sheet. You can ignore this by changing the 'Handling extra data' field, which you can find under 'Options'.`, @@ -238,9 +242,9 @@ export async function execute( }); data.push(items[i].json); } - if (handlingExtraData === 'insertInNewColumn') { + if (handlingExtraDataOption === 'insertInNewColumn') { Object.keys(items[i].json).forEach((key) => { - if (columnNames.includes(key) === false) { + if (!columnNames.includes(key)) { newColumns.add(key); } }); @@ -255,7 +259,7 @@ export async function execute( if (entry.column === 'newColumn') { const columnName = entry.columnName as string; - if (columnNames.includes(columnName) === false) { + if (!columnNames.includes(columnName)) { newColumns.add(columnName); } 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 7c26284485..61566cfd8c 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 @@ -91,7 +91,7 @@ export async function execute( continue; } - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); const properties = { ...options }; properties.title = sheetTitle; diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/read.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/read.operation.ts index a12381d438..14731532b5 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/read.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/read.operation.ts @@ -6,10 +6,11 @@ import { prepareSheetData, untilSheetSelected, } from '../../helpers/GoogleSheets.utils'; -import { ILookupValues, SheetProperties } from '../../helpers/GoogleSheets.types'; import { dataLocationOnSheet, outputFormatting } from './commonDescription'; import { + ILookupValues, RangeDetectionOptions, + SheetProperties, SheetRangeData, ValueRenderOption, } from '../../helpers/GoogleSheets.types'; @@ -110,12 +111,12 @@ export async function execute( sheet: GoogleSheet, sheetName: string, ): Promise { - const options = this.getNodeParameter('options', 0, {}) as IDataObject; - const outputFormatting = - (((options.outputFormatting as IDataObject) || {}).values as IDataObject) || {}; + const options = this.getNodeParameter('options', 0, {}); + const outputFormattingOption = + ((options.outputFormatting as IDataObject)?.values as IDataObject) || {}; const dataLocationOnSheetOptions = - (((options.dataLocationOnSheet as IDataObject) || {}).values as RangeDetectionOptions) || {}; + ((options.dataLocationOnSheet as IDataObject)?.values as RangeDetectionOptions) || {}; if (dataLocationOnSheetOptions.rangeDefinition === undefined) { dataLocationOnSheetOptions.rangeDefinition = 'detectAutomatically'; @@ -123,8 +124,9 @@ export async function execute( const range = getRangeString(sheetName, dataLocationOnSheetOptions); - const valueRenderMode = (outputFormatting.general || 'UNFORMATTED_VALUE') as ValueRenderOption; - const dateTimeRenderOption = (outputFormatting.date || 'FORMATTED_STRING') as string; + const valueRenderMode = (outputFormattingOption.general || + 'UNFORMATTED_VALUE') as ValueRenderOption; + const dateTimeRenderOption = (outputFormattingOption.date || 'FORMATTED_STRING') as string; const sheetData = (await sheet.getData( range, 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 8030ba7c96..1740a5ce17 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 @@ -20,9 +20,7 @@ export async function execute( }, ]; - let responseData; - - responseData = await apiRequest.call( + const responseData = await apiRequest.call( this, 'POST', `/v4/spreadsheets/${spreadsheetId}:batchUpdate`, diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts index 326e9804b9..8570abbb83 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts @@ -1,8 +1,12 @@ import { IExecuteFunctions } from 'n8n-core'; -import { ISheetUpdateData, SheetProperties } from '../../helpers/GoogleSheets.types'; +import { + ISheetUpdateData, + SheetProperties, + ValueInputOption, + ValueRenderOption, +} from '../../helpers/GoogleSheets.types'; import { IDataObject, INodeExecutionData, NodeOperationError } from 'n8n-workflow'; import { GoogleSheet } from '../../helpers/GoogleSheet'; -import { ValueInputOption, ValueRenderOption } from '../../helpers/GoogleSheets.types'; import { untilSheetSelected } from '../../helpers/GoogleSheets.utils'; import { cellFormat, handlingExtraData, locationDefine } from './commonDescription'; @@ -165,21 +169,21 @@ export async function execute( const valueInputMode = this.getNodeParameter('options.cellFormat', 0, 'RAW') as ValueInputOption; const range = `${sheetName}!A:Z`; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const valueRenderMode = (options.valueRenderMode || 'UNFORMATTED_VALUE') as ValueRenderOption; - const locationDefine = ((options.locationDefine as IDataObject) || {}).values as IDataObject; + const locationDefineOptions = (options.locationDefine as IDataObject)?.values as IDataObject; let headerRow = 0; let firstDataRow = 1; - if (locationDefine) { - if (locationDefine.headerRow) { - headerRow = parseInt(locationDefine.headerRow as string, 10) - 1; + if (locationDefineOptions) { + if (locationDefineOptions.headerRow) { + headerRow = parseInt(locationDefineOptions.headerRow as string, 10) - 1; } - if (locationDefine.firstDataRow) { - firstDataRow = parseInt(locationDefine.firstDataRow as string, 10) - 1; + if (locationDefineOptions.firstDataRow) { + firstDataRow = parseInt(locationDefineOptions.firstDataRow as string, 10) - 1; } } @@ -221,13 +225,13 @@ export async function execute( const data: IDataObject[] = []; if (dataMode === 'autoMapInputData') { - const handlingExtraData = (options.handlingExtraData as string) || 'insertInNewColumn'; - if (handlingExtraData === 'ignoreIt') { + const handlingExtraDataOption = (options.handlingExtraData as string) || 'insertInNewColumn'; + if (handlingExtraDataOption === 'ignoreIt') { data.push(items[i].json); } - if (handlingExtraData === 'error') { + if (handlingExtraDataOption === 'error') { Object.keys(items[i].json).forEach((key) => { - if (columnNames.includes(key) === false) { + if (!columnNames.includes(key)) { throw new NodeOperationError(this.getNode(), `Unexpected fields in node input`, { itemIndex: i, description: `The input field '${key}' doesn't match any column in the Sheet. You can ignore this by changing the 'Handling extra data' field, which you can find under 'Options'.`, @@ -236,9 +240,9 @@ export async function execute( }); data.push(items[i].json); } - if (handlingExtraData === 'insertInNewColumn') { + if (handlingExtraDataOption === 'insertInNewColumn') { Object.keys(items[i].json).forEach((key) => { - if (columnNames.includes(key) === false) { + if (!columnNames.includes(key)) { newColumns.add(key); } }); @@ -253,7 +257,7 @@ export async function execute( if (entry.column === 'newColumn') { const columnName = entry.columnName as string; - if (columnNames.includes(columnName) === false) { + if (!columnNames.includes(columnName)) { newColumns.add(columnName); } 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 5ed5490bd0..391a627620 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 @@ -131,7 +131,7 @@ export async function execute(this: IExecuteFunctions): Promise ((sheet.properties as IDataObject) || {}).title, - ); + return ((sheets as IDataObject[]) || []).map((entry) => (entry.properties as IDataObject)?.title); } export function mapFields(this: IExecuteFunctions, inputSize: number) { @@ -213,7 +211,7 @@ export async function autoMapInputData( ) { const returnData: IDataObject[] = []; const [sheetName, _sheetRange] = sheetNameWithRange.split('!'); - const locationDefine = ((options.locationDefine as IDataObject) || {}).values as IDataObject; + const locationDefine = (options.locationDefine as IDataObject)?.values as IDataObject; const handlingExtraData = (options.handlingExtraData as string) || 'insertInNewColumn'; let headerRow = 1; @@ -242,7 +240,7 @@ export async function autoMapInputData( items.forEach((item) => { Object.keys(item.json).forEach((key) => { - if (key !== ROW_NUMBER && columnNames.includes(key) === false) { + if (key !== ROW_NUMBER && !columnNames.includes(key)) { newColumns.add(key); } }); @@ -268,7 +266,7 @@ export async function autoMapInputData( if (handlingExtraData === 'error') { items.forEach((item, itemIndex) => { Object.keys(item.json).forEach((key) => { - if (columnNames.includes(key) === false) { + if (!columnNames.includes(key)) { throw new NodeOperationError(this.getNode(), `Unexpected fields in node input`, { itemIndex, description: `The input field '${key}' doesn't match any column in the Sheet. You can ignore this by changing the 'Handling extra data' field, which you can find under 'Options'.`, @@ -285,8 +283,8 @@ export async function autoMapInputData( export function sortLoadOptions(data: INodePropertyOptions[] | INodeListSearchItems[]) { const returnData = [...data]; returnData.sort((a, b) => { - const aName = (a.name as string).toLowerCase(); - const bName = (b.name as string).toLowerCase(); + const aName = a.name.toLowerCase(); + const bName = b.name.toLowerCase(); if (aName < bName) { return -1; } diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/methods/loadOptions.ts b/packages/nodes-base/nodes/Google/Sheet/v2/methods/loadOptions.ts index 84de3ad324..db73812081 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/methods/loadOptions.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/methods/loadOptions.ts @@ -20,14 +20,14 @@ export async function getSheets(this: ILoadOptionsFunctions): Promise { @@ -105,22 +105,22 @@ function getAccessToken( const now = moment().unix(); credentials.email = credentials.email.trim(); - const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); + const privateKey = credentials.privateKey.replace(/\\n/g, '\n').trim(); const signature = jwt.sign( { - iss: credentials.email as string, - sub: credentials.email as string, + iss: credentials.email, + sub: credentials.email, scope: scopes.join(' '), aud: `https://oauth2.googleapis.com/token`, iat: now, exp: now + 3600, }, - privateKey as string, + privateKey, { algorithm: 'RS256', header: { - kid: privateKey as string, + kid: privateKey, typ: 'JWT', alg: 'RS256', }, @@ -140,6 +140,5 @@ function getAccessToken( json: true, }; - //@ts-ignore - return this.helpers.request(options); + return this.helpers.request!(options); } diff --git a/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts b/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts index eede8baf93..a7e1a31e37 100644 --- a/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts @@ -54,9 +54,9 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts b/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts index 1848f1f595..320838769e 100644 --- a/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts +++ b/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts @@ -531,7 +531,7 @@ export class YouTube implements INodeType { if (options.tags) { //@ts-ignore - body.snippet.tags = (options.tags as string).split(',') as string[]; + body.snippet.tags = (options.tags as string).split(','); } if (options.description) { @@ -578,7 +578,7 @@ export class YouTube implements INodeType { if (updateFields.tags) { //@ts-ignore - body.snippet.tags = (updateFields.tags as string).split(',') as string[]; + body.snippet.tags = (updateFields.tags as string).split(','); } if (updateFields.privacyStatus) { @@ -919,7 +919,7 @@ export class YouTube implements INodeType { if (options.tags) { //@ts-ignore - data.snippet.tags = (options.tags as string).split(',') as string[]; + data.snippet.tags = (options.tags as string).split(','); } if (options.embeddable) { @@ -995,7 +995,7 @@ export class YouTube implements INodeType { if (updateFields.tags) { //@ts-ignore - body.snippet.tags = (updateFields.tags as string).split(',') as string[]; + body.snippet.tags = (updateFields.tags as string).split(','); } if (updateFields.embeddable) { @@ -1091,7 +1091,7 @@ export class YouTube implements INodeType { ); responseData = responseData.items; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } diff --git a/packages/nodes-base/nodes/Grafana/Grafana.node.ts b/packages/nodes-base/nodes/Grafana/Grafana.node.ts index c9c1b3d3b0..bb56b84de0 100644 --- a/packages/nodes-base/nodes/Grafana/Grafana.node.ts +++ b/packages/nodes-base/nodes/Grafana/Grafana.node.ts @@ -240,7 +240,7 @@ export class Grafana implements INodeType { const dashboards = (await grafanaApiRequest.call(this, 'GET', '/search')) as Array<{ title: string; }>; - const titles = dashboards.map(({ title }) => title); + const titles = dashboards.map(({ title: entry }) => entry); if (titles.includes(title)) { throw new NodeApiError(this.getNode(), { diff --git a/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts b/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts index a438611401..8bdebbaf2b 100644 --- a/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts +++ b/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts @@ -351,11 +351,7 @@ export class GraphQL implements INodeType { method: requestMethod, uri: endpoint, simple: false, - rejectUnauthorized: !this.getNodeParameter( - 'allowUnauthorizedCerts', - itemIndex, - false, - ) as boolean, + rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false), }; // Add credentials if any are set @@ -372,7 +368,7 @@ export class GraphQL implements INodeType { if (!requestOptions.qs) { requestOptions.qs = {}; } - requestOptions.qs![httpQueryAuth.name as string] = httpQueryAuth.value; + requestOptions.qs[httpQueryAuth.name as string] = httpQueryAuth.value; } if (httpDigestAuth !== undefined) { requestOptions.auth = { diff --git a/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts b/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts index c597cecf5c..93309c4aa3 100644 --- a/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts +++ b/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts @@ -77,6 +77,7 @@ export class GumroadTrigger implements INodeType { }, ], }; + // @ts-ignore webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts b/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts index e592a0ba65..6a1b9d1372 100644 --- a/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function hackerNewsApiRequest( }; try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts b/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts index 9493c3f7f2..b0303482fd 100644 --- a/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts +++ b/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts @@ -329,7 +329,7 @@ export class HackerNews implements INodeType { } let responseData; - if (returnAll === true) { + if (returnAll) { responseData = await hackerNewsApiRequestAllItems.call(this, 'GET', endpoint, qs); } else { responseData = await hackerNewsApiRequest.call(this, 'GET', endpoint, qs); diff --git a/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts b/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts index 5f089bc707..8ee258e51d 100644 --- a/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts @@ -211,14 +211,14 @@ export function qsSetStatus(status: string) { if (!status) return {}; const qs: IDataObject = {}; if (status === 'all') { - qs['includeinactive'] = true; - qs['includeactive'] = true; + qs.includeinactive = true; + qs.includeactive = true; } else if (status === 'active') { - qs['includeinactive'] = false; - qs['includeactive'] = true; + qs.includeinactive = false; + qs.includeactive = true; } else { - qs['includeinactive'] = true; - qs['includeactive'] = false; + qs.includeinactive = true; + qs.includeactive = false; } return qs; } diff --git a/packages/nodes-base/nodes/HaloPSA/HaloPSA.node.ts b/packages/nodes-base/nodes/HaloPSA/HaloPSA.node.ts index 51768fe386..8f656772a3 100644 --- a/packages/nodes-base/nodes/HaloPSA/HaloPSA.node.ts +++ b/packages/nodes-base/nodes/HaloPSA/HaloPSA.node.ts @@ -270,8 +270,7 @@ export class HaloPSA implements INodeType { if (operation === 'get') { const clientId = this.getNodeParameter('clientId', i) as string; const simplify = this.getNodeParameter('simplify', i) as boolean; - let response; - response = await haloPSAApiRequest.call( + const response = await haloPSAApiRequest.call( this, 'GET', `/client/${clientId}`, @@ -378,8 +377,7 @@ export class HaloPSA implements INodeType { if (operation === 'get') { const siteId = this.getNodeParameter('siteId', i) as string; const simplify = this.getNodeParameter('simplify', i) as boolean; - let response; - response = await haloPSAApiRequest.call( + const response = await haloPSAApiRequest.call( this, 'GET', `/site/${siteId}`, @@ -488,8 +486,7 @@ export class HaloPSA implements INodeType { if (operation === 'get') { const ticketId = this.getNodeParameter('ticketId', i) as string; const simplify = this.getNodeParameter('simplify', i) as boolean; - let response; - response = await haloPSAApiRequest.call( + const response = await haloPSAApiRequest.call( this, 'GET', `/tickets/${ticketId}`, @@ -597,8 +594,7 @@ export class HaloPSA implements INodeType { if (operation === 'get') { const userId = this.getNodeParameter('userId', i) as string; const simplify = this.getNodeParameter('simplify', i) as boolean; - let response; - response = await haloPSAApiRequest.call( + const response = await haloPSAApiRequest.call( this, 'GET', `/users/${userId}`, diff --git a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts index adcc89ecf2..178cb19c44 100644 --- a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts @@ -12,7 +12,7 @@ import { IDataObject, NodeApiError } from 'n8n-workflow'; export async function harvestApiRequest( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, - qs: IDataObject = {}, + qs: IDataObject, path: string, body: IDataObject = {}, option: IDataObject = {}, @@ -42,7 +42,7 @@ export async function harvestApiRequest( const credentials = await this.getCredentials('harvestApi'); //@ts-ignore - options.headers['Authorization'] = `Bearer ${credentials.accessToken}`; + options.headers.Authorization = `Bearer ${credentials.accessToken}`; return await this.helpers.request!(options); } else { @@ -60,7 +60,7 @@ export async function harvestApiRequest( export async function harvestApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, - qs: IDataObject = {}, + qs: IDataObject, uri: string, resource: string, body: IDataObject = {}, diff --git a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts index 2407dbd76b..1e777057ec 100644 --- a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts @@ -66,11 +66,7 @@ export async function helpscoutApiRequestAllItems( if (query.limit && query.limit <= returnData.length) { return returnData; } - } while ( - responseData['_links'] !== undefined && - responseData['_links'].next !== undefined && - responseData['_links'].next.href !== undefined - ); + } while (responseData._links?.next?.href !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts index a8030ac7d7..881f9b8898 100644 --- a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts +++ b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts @@ -195,12 +195,12 @@ export class HelpScout implements INodeType { ); } if (threads) { - for (let i = 0; i < threads.length; i++) { - if (threads[i].type === '' || threads[i].text === '') { + for (let index = 0; index < threads.length; index++) { + if (threads[index].type === '' || threads[index].text === '') { throw new NodeOperationError(this.getNode(), 'Chat Threads cannot be empty'); } - if (threads[i].type !== 'note') { - threads[i].customer = body.customer; + if (threads[index].type !== 'note') { + threads[index].customer = body.customer; } } body.threads = threads; @@ -518,9 +518,7 @@ export class HelpScout implements INodeType { }; body.attachments?.push.apply( body.attachments, - (attachments.attachmentsBinary as IDataObject[]).map( - mapFunction, - ) as IAttachment[], + (attachments.attachmentsBinary as IDataObject[]).map(mapFunction), ); } } diff --git a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts index 2b0d7cdd8d..e24a852446 100644 --- a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts @@ -70,7 +70,7 @@ export async function getHomeAssistantServices( const services = await homeAssistantApiRequest.call(this, 'GET', '/services'); if (domain === '') { // If no domain specified return domains - const domains = services.map(({ domain }: IDataObject) => domain as string).sort(); + const domains = services.map(({ domain: service }: IDataObject) => service as string).sort(); returnData.push(...domains.map((service: string) => ({ name: service, value: service }))); return returnData; } else { diff --git a/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts b/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts index 95c213afc3..eb850514c1 100644 --- a/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts +++ b/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts @@ -159,18 +159,18 @@ export class HomeAssistant implements INodeType { loadOptions: { async getAllEntities(this: ILoadOptionsFunctions): Promise { - return await getHomeAssistantEntities.call(this); + return getHomeAssistantEntities.call(this); }, async getCameraEntities(this: ILoadOptionsFunctions): Promise { - return await getHomeAssistantEntities.call(this, 'camera'); + return getHomeAssistantEntities.call(this, 'camera'); }, async getDomains(this: ILoadOptionsFunctions): Promise { - return await getHomeAssistantServices.call(this); + return getHomeAssistantServices.call(this); }, async getDomainServices(this: ILoadOptionsFunctions): Promise { const currentDomain = this.getCurrentNodeParameter('domain') as string; if (currentDomain) { - return await getHomeAssistantServices.call(this, currentDomain); + return getHomeAssistantServices.call(this, currentDomain); } else { return []; } diff --git a/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts b/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts index 601c4b7394..d359c10fcc 100644 --- a/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts +++ b/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts @@ -219,7 +219,7 @@ export class HtmlExtract implements INodeType { 'extractionValues', itemIndex, ) as IDataObject; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); const sourceData = this.getNodeParameter('sourceData', itemIndex) as string; item = items[itemIndex]; @@ -275,18 +275,18 @@ export class HtmlExtract implements INodeType { for (const valueData of extractionValues.values as IValueData[]) { htmlElement = $(valueData.cssSelector); - if (valueData.returnArray === true) { + if (valueData.returnArray) { // An array should be returned so itterate over one // value at a time - newItem.json[valueData.key as string] = []; + newItem.json[valueData.key] = []; htmlElement.each((i, el) => { - (newItem.json[valueData.key as string] as Array).push( + (newItem.json[valueData.key] as Array).push( getValue($(el), valueData, options), ); }); } else { // One single value should be returned - newItem.json[valueData.key as string] = getValue(htmlElement, valueData, options); + newItem.json[valueData.key] = getValue(htmlElement, valueData, options); } } returnData.push(newItem); diff --git a/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts b/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts index 3d9d062492..2849d09312 100644 --- a/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts @@ -2,7 +2,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IDataObject, INodeExecutionData, INodeType, @@ -654,9 +653,9 @@ export class HttpRequestV1 implements INodeType { const requestPromises = []; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { const requestMethod = this.getNodeParameter('requestMethod', itemIndex) as string; - const parametersAreJson = this.getNodeParameter('jsonParameters', itemIndex) as boolean; + const parametersAreJson = this.getNodeParameter('jsonParameters', itemIndex); - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); const url = this.getNodeParameter('url', itemIndex) as string; if ( @@ -672,21 +671,17 @@ export class HttpRequestV1 implements INodeType { } } - const fullResponse = !!options.fullResponse as boolean; + const fullResponse = !!options.fullResponse; requestOptions = { headers: {}, method: requestMethod, uri: url, gzip: true, - rejectUnauthorized: !this.getNodeParameter( - 'allowUnauthorizedCerts', - itemIndex, - false, - ) as boolean, + rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false), }; - if (fullResponse === true) { + if (fullResponse) { // @ts-ignore requestOptions.resolveWithFullResponse = true; } @@ -716,11 +711,11 @@ export class HttpRequestV1 implements INodeType { requestOptions.useQuerystring = true; } - if (parametersAreJson === true) { + if (parametersAreJson) { // Parameters are defined as JSON let optionData: OptionData; for (const parameterName of Object.keys(jsonParameters)) { - optionData = jsonParameters[parameterName] as OptionData; + optionData = jsonParameters[parameterName]; const tempValue = this.getNodeParameter(parameterName, itemIndex, '') as string | object; const sendBinaryData = this.getNodeParameter( 'sendBinaryData', @@ -728,8 +723,8 @@ export class HttpRequestV1 implements INodeType { false, ) as boolean; - if (optionData.name === 'body' && parametersAreJson === true) { - if (sendBinaryData === true) { + if (optionData.name === 'body' && parametersAreJson) { + if (sendBinaryData) { const contentTypesAllowed = ['raw', 'multipart-form-data']; if (!contentTypesAllowed.includes(options.bodyContentType as string)) { @@ -800,7 +795,7 @@ export class HttpRequestV1 implements INodeType { ); } - const binaryProperty = item.binary[binaryPropertyName] as IBinaryData; + const binaryProperty = item.binary[binaryPropertyName]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( itemIndex, binaryPropertyName, @@ -855,8 +850,8 @@ export class HttpRequestV1 implements INodeType { // @ts-ignore requestOptions[optionName] = {}; for (const parameterData of setUiParameter!.parameter as IDataObject[]) { - const parameterDataName = parameterData!.name as string; - const newValue = parameterData!.value; + const parameterDataName = parameterData.name as string; + const newValue = parameterData.value; if (optionName === 'qs') { const computeNewValue = (oldValue: unknown) => { if (typeof oldValue === 'string') { @@ -933,7 +928,7 @@ export class HttpRequestV1 implements INodeType { if (!requestOptions.qs) { requestOptions.qs = {}; } - requestOptions.qs![httpQueryAuth.name as string] = httpQueryAuth.value; + requestOptions.qs[httpQueryAuth.name as string] = httpQueryAuth.value; } if (httpDigestAuth !== undefined) { requestOptions.auth = { @@ -943,14 +938,14 @@ export class HttpRequestV1 implements INodeType { }; } - if (requestOptions.headers!['accept'] === undefined) { + if (requestOptions.headers!.accept === undefined) { if (responseFormat === 'json') { - requestOptions.headers!['accept'] = 'application/json,text/*;q=0.99'; + requestOptions.headers!.accept = 'application/json,text/*;q=0.99'; } else if (responseFormat === 'string') { - requestOptions.headers!['accept'] = + requestOptions.headers!.accept = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, */*;q=0.1'; } else { - requestOptions.headers!['accept'] = + requestOptions.headers!.accept = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7'; } } @@ -994,7 +989,7 @@ export class HttpRequestV1 implements INodeType { response = promisesResponses.shift(); if (response!.status !== 'fulfilled') { - if (this.continueOnFail() !== true) { + if (!this.continueOnFail()) { // throw error; throw new NodeApiError(this.getNode(), response); } else { @@ -1013,10 +1008,10 @@ export class HttpRequestV1 implements INodeType { response = response.value; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); const url = this.getNodeParameter('url', itemIndex) as string; - const fullResponse = !!options.fullResponse as boolean; + const fullResponse = !!options.fullResponse; if (responseFormat === 'file') { const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; @@ -1039,7 +1034,7 @@ export class HttpRequestV1 implements INodeType { const fileName = url.split('/').pop(); - if (fullResponse === true) { + if (fullResponse) { const returnItem: IDataObject = {}; for (const property of fullReponseProperties) { if (property === 'body') { @@ -1067,7 +1062,7 @@ export class HttpRequestV1 implements INodeType { } else if (responseFormat === 'string') { const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; - if (fullResponse === true) { + if (fullResponse) { const returnItem: IDataObject = {}; for (const property of fullReponseProperties) { if (property === 'body') { @@ -1095,7 +1090,7 @@ export class HttpRequestV1 implements INodeType { } } else { // responseFormat: 'json' - if (fullResponse === true) { + if (fullResponse) { const returnItem: IDataObject = {}; for (const property of fullReponseProperties) { returnItem[property] = response![property]; @@ -1133,6 +1128,7 @@ export class HttpRequestV1 implements INodeType { } if (options.splitIntoItems === true && Array.isArray(response)) { + // eslint-disable-next-line @typescript-eslint/no-loop-func response.forEach((item) => returnItems.push({ json: item, diff --git a/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts b/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts index e041be522a..ab118f8afa 100644 --- a/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts @@ -1,6 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IDataObject, INodeExecutionData, INodeType, @@ -688,9 +687,9 @@ export class HttpRequestV2 implements INodeType { const requestPromises = []; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { const requestMethod = this.getNodeParameter('requestMethod', itemIndex) as string; - const parametersAreJson = this.getNodeParameter('jsonParameters', itemIndex) as boolean; + const parametersAreJson = this.getNodeParameter('jsonParameters', itemIndex); - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); const url = this.getNodeParameter('url', itemIndex) as string; if ( @@ -706,21 +705,17 @@ export class HttpRequestV2 implements INodeType { } } - const fullResponse = !!options.fullResponse as boolean; + const fullResponse = !!options.fullResponse; requestOptions = { headers: {}, method: requestMethod, uri: url, gzip: true, - rejectUnauthorized: !this.getNodeParameter( - 'allowUnauthorizedCerts', - itemIndex, - false, - ) as boolean, + rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false), }; - if (fullResponse === true) { + if (fullResponse) { // @ts-ignore requestOptions.resolveWithFullResponse = true; } @@ -750,11 +745,11 @@ export class HttpRequestV2 implements INodeType { requestOptions.useQuerystring = true; } - if (parametersAreJson === true) { + if (parametersAreJson) { // Parameters are defined as JSON let optionData: OptionData; for (const parameterName of Object.keys(jsonParameters)) { - optionData = jsonParameters[parameterName] as OptionData; + optionData = jsonParameters[parameterName]; const tempValue = this.getNodeParameter(parameterName, itemIndex, '') as string | object; const sendBinaryData = this.getNodeParameter( 'sendBinaryData', @@ -762,8 +757,8 @@ export class HttpRequestV2 implements INodeType { false, ) as boolean; - if (optionData.name === 'body' && parametersAreJson === true) { - if (sendBinaryData === true) { + if (optionData.name === 'body' && parametersAreJson) { + if (sendBinaryData) { const contentTypesAllowed = ['raw', 'multipart-form-data']; if (!contentTypesAllowed.includes(options.bodyContentType as string)) { @@ -834,7 +829,7 @@ export class HttpRequestV2 implements INodeType { ); } - const binaryProperty = item.binary[binaryPropertyName] as IBinaryData; + const binaryProperty = item.binary[binaryPropertyName]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( itemIndex, binaryPropertyName, @@ -889,8 +884,8 @@ export class HttpRequestV2 implements INodeType { // @ts-ignore requestOptions[optionName] = {}; for (const parameterData of setUiParameter!.parameter as IDataObject[]) { - const parameterDataName = parameterData!.name as string; - const newValue = parameterData!.value; + const parameterDataName = parameterData.name as string; + const newValue = parameterData.value; if (optionName === 'qs') { const computeNewValue = (oldValue: unknown) => { if (typeof oldValue === 'string') { @@ -967,7 +962,7 @@ export class HttpRequestV2 implements INodeType { if (!requestOptions.qs) { requestOptions.qs = {}; } - requestOptions.qs![httpQueryAuth.name as string] = httpQueryAuth.value; + requestOptions.qs[httpQueryAuth.name as string] = httpQueryAuth.value; } if (httpDigestAuth !== undefined) { requestOptions.auth = { @@ -977,14 +972,14 @@ export class HttpRequestV2 implements INodeType { }; } - if (requestOptions.headers!['accept'] === undefined) { + if (requestOptions.headers!.accept === undefined) { if (responseFormat === 'json') { - requestOptions.headers!['accept'] = 'application/json,text/*;q=0.99'; + requestOptions.headers!.accept = 'application/json,text/*;q=0.99'; } else if (responseFormat === 'string') { - requestOptions.headers!['accept'] = + requestOptions.headers!.accept = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, */*;q=0.1'; } else { - requestOptions.headers!['accept'] = + requestOptions.headers!.accept = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7'; } } @@ -1042,7 +1037,7 @@ export class HttpRequestV2 implements INodeType { response = promisesResponses.shift(); if (response!.status !== 'fulfilled') { - if (this.continueOnFail() !== true) { + if (!this.continueOnFail()) { // throw error; throw new NodeApiError(this.getNode(), response); } else { @@ -1061,10 +1056,10 @@ export class HttpRequestV2 implements INodeType { response = response.value; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); const url = this.getNodeParameter('url', itemIndex) as string; - const fullResponse = !!options.fullResponse as boolean; + const fullResponse = !!options.fullResponse; if (responseFormat === 'file') { const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; @@ -1087,7 +1082,7 @@ export class HttpRequestV2 implements INodeType { const fileName = url.split('/').pop(); - if (fullResponse === true) { + if (fullResponse) { const returnItem: IDataObject = {}; for (const property of fullReponseProperties) { if (property === 'body') { @@ -1115,7 +1110,7 @@ export class HttpRequestV2 implements INodeType { } else if (responseFormat === 'string') { const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; - if (fullResponse === true) { + if (fullResponse) { const returnItem: IDataObject = {}; for (const property of fullReponseProperties) { if (property === 'body') { @@ -1143,7 +1138,7 @@ export class HttpRequestV2 implements INodeType { } } else { // responseFormat: 'json' - if (fullResponse === true) { + if (fullResponse) { const returnItem: IDataObject = {}; for (const property of fullReponseProperties) { returnItem[property] = response![property]; @@ -1181,6 +1176,7 @@ export class HttpRequestV2 implements INodeType { } if (options.splitIntoItems === true && Array.isArray(response)) { + // eslint-disable-next-line @typescript-eslint/no-loop-func response.forEach((item) => returnItems.push({ json: item, diff --git a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts index 0b11e5aec5..437f96bb4f 100644 --- a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts @@ -1023,7 +1023,7 @@ export class HttpRequestV3 implements INodeType { requestOptions.resolveWithFullResponse = true; } - if (redirect?.redirect?.followRedirects !== false) { + if (redirect?.redirect?.followRedirects) { requestOptions.followRedirect = true; requestOptions.followAllRedirects = true; } @@ -1032,7 +1032,7 @@ export class HttpRequestV3 implements INodeType { requestOptions.maxRedirects = redirect?.redirect?.maxRedirects; } - if (response?.response?.neverError === true) { + if (response?.response?.neverError) { requestOptions.simple = false; } @@ -1222,7 +1222,7 @@ export class HttpRequestV3 implements INodeType { if (!requestOptions.qs) { requestOptions.qs = {}; } - requestOptions.qs![httpQueryAuth.name as string] = httpQueryAuth.value; + requestOptions.qs[httpQueryAuth.name as string] = httpQueryAuth.value; } if (httpDigestAuth !== undefined) { requestOptions.auth = { @@ -1232,14 +1232,14 @@ export class HttpRequestV3 implements INodeType { }; } - if (requestOptions.headers!['accept'] === undefined) { + if (requestOptions.headers!.accept === undefined) { if (responseFormat === 'json') { - requestOptions.headers!['accept'] = 'application/json,text/*;q=0.99'; + requestOptions.headers!.accept = 'application/json,text/*;q=0.99'; } else if (responseFormat === 'text') { - requestOptions.headers!['accept'] = + requestOptions.headers!.accept = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, */*;q=0.1'; } else { - requestOptions.headers!['accept'] = + requestOptions.headers!.accept = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7'; } } @@ -1298,7 +1298,7 @@ export class HttpRequestV3 implements INodeType { response = promisesResponses.shift(); if (response!.status !== 'fulfilled') { - if (this.continueOnFail() !== true) { + if (!this.continueOnFail()) { if (autoDetectResponseFormat && response.reason.error instanceof Buffer) { response.reason.error = Buffer.from(response.reason.error).toString(); } @@ -1327,7 +1327,7 @@ export class HttpRequestV3 implements INodeType { 'autodetect', ) as string; - const fullResponse = this.getNodeParameter( + fullResponse = this.getNodeParameter( 'options.response.response.fullResponse', 0, false, @@ -1380,7 +1380,7 @@ export class HttpRequestV3 implements INodeType { const fileName = url.split('/').pop(); - if (fullResponse === true) { + if (fullResponse) { const returnItem: IDataObject = {}; for (const property of fullReponseProperties) { if (property === 'body') { @@ -1411,7 +1411,7 @@ export class HttpRequestV3 implements INodeType { 0, 'data', ) as string; - if (fullResponse === true) { + if (fullResponse) { const returnItem: IDataObject = {}; for (const property of fullReponseProperties) { if (property === 'body') { @@ -1477,6 +1477,7 @@ export class HttpRequestV3 implements INodeType { } if (Array.isArray(response)) { + // eslint-disable-next-line @typescript-eslint/no-loop-func response.forEach((item) => returnItems.push({ json: item, diff --git a/packages/nodes-base/nodes/Hubspot/ContactDescription.ts b/packages/nodes-base/nodes/Hubspot/ContactDescription.ts index 5548933580..1be54f8d4b 100644 --- a/packages/nodes-base/nodes/Hubspot/ContactDescription.ts +++ b/packages/nodes-base/nodes/Hubspot/ContactDescription.ts @@ -572,7 +572,7 @@ export const contactFields: INodeProperties[] = [ }, { displayName: 'List Memberships', - name: 'listMerberships', + name: 'listMemberships', type: 'boolean', default: true, description: 'Whether current list memberships should be fetched for the contact', @@ -683,7 +683,7 @@ export const contactFields: INodeProperties[] = [ }, { displayName: 'List Memberships', - name: 'listMerberships', + name: 'listMemberships', type: 'boolean', default: true, description: 'Whether current list memberships should be fetched for the contact', @@ -812,7 +812,7 @@ export const contactFields: INodeProperties[] = [ }, { displayName: 'List Memberships', - name: 'listMerberships', + name: 'listMemberships', type: 'boolean', default: true, description: 'Whether current list memberships should be fetched for the contact', diff --git a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts index f37f37c5f6..6ccfeb24fe 100644 --- a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts @@ -45,7 +45,7 @@ export async function hubspotApiRequest( try { if (authenticationMethod === 'apiKey' || authenticationMethod === 'appToken') { const credentialType = authenticationMethod === 'apiKey' ? 'hubspotApi' : 'hubspotAppToken'; - return this.helpers.requestWithAuthentication.call(this, credentialType, options); + return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } else if (authenticationMethod === 'developerApi') { if (endpoint.includes('webhooks')) { const credentials = await this.getCredentials('hubspotDeveloperApi'); @@ -94,15 +94,15 @@ export async function hubspotApiRequestAllItems( query.offset = responseData.offset; query.vidOffset = responseData['vid-offset']; //Used by Search endpoints - if (responseData['paging']) { - body.after = responseData['paging']['next']['after']; + if (responseData.paging) { + body.after = responseData.paging.next.after; } returnData.push.apply(returnData, responseData[propertyName]); //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; } - } while (responseData['hasMore'] || responseData['has-more'] || responseData['paging']); + } while (responseData.hasMore || responseData['has-more'] || responseData.paging); return returnData; } @@ -2007,5 +2007,5 @@ export async function validateCredentials( options.headers = { Authorization: `Bearer ${appToken}` }; } - return await this.helpers.request(options); + return this.helpers.request(options); } diff --git a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts index 1af85eb74e..c6468296c2 100644 --- a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts +++ b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts @@ -24,6 +24,7 @@ import { getTaskMetadata, hubspotApiRequest, hubspotApiRequestAllItems, + validateCredentials, } from './GenericFunctions'; import { contactFields, contactOperations } from './ContactDescription'; @@ -46,7 +47,6 @@ import { IAssociation, IDeal } from './DealInterface'; import { snakeCase } from 'change-case'; -import { validateCredentials } from './GenericFunctions'; export class Hubspot implements INodeType { description: INodeTypeDescription = { displayName: 'HubSpot', @@ -1303,7 +1303,6 @@ export class Hubspot implements INodeType { if (resolveData) { const isNew = responseData.isNew; - const qs: IDataObject = {}; if (additionalFields.properties) { qs.property = additionalFields.properties as string[]; } @@ -1324,8 +1323,8 @@ export class Hubspot implements INodeType { if (additionalFields.formSubmissionMode) { qs.formSubmissionMode = additionalFields.formSubmissionMode as string; } - if (additionalFields.listMerberships) { - qs.showListMemberships = additionalFields.listMerberships as boolean; + if (additionalFields.listMemberships) { + qs.showListMemberships = additionalFields.listMemberships as boolean; } if (additionalFields.properties) { qs.property = additionalFields.properties as string[]; @@ -1343,8 +1342,8 @@ export class Hubspot implements INodeType { if (additionalFields.formSubmissionMode) { qs.formSubmissionMode = additionalFields.formSubmissionMode as string; } - if (additionalFields.listMerberships) { - qs.showListMemberships = additionalFields.listMerberships as boolean; + if (additionalFields.listMemberships) { + qs.showListMemberships = additionalFields.listMemberships as boolean; } if (additionalFields.properties) { qs.property = additionalFields.properties as string[]; @@ -1370,14 +1369,13 @@ export class Hubspot implements INodeType { } //https://developers.hubspot.com/docs/methods/contacts/get_recently_created_contacts if (operation === 'getRecentlyCreatedUpdated') { - let endpoint; const returnAll = this.getNodeParameter('returnAll', 0); const filters = this.getNodeParameter('filters', i); if (filters.formSubmissionMode) { qs.formSubmissionMode = filters.formSubmissionMode as string; } - if (filters.listMerberships) { - qs.showListMemberships = filters.listMerberships as boolean; + if (filters.listMemberships) { + qs.showListMemberships = filters.listMemberships as boolean; } if (filters.properties) { qs.property = filters.properties as string[]; @@ -1386,7 +1384,7 @@ export class Hubspot implements INodeType { qs.propertyMode = snakeCase(filters.propertyMode as string); } - endpoint = '/contacts/v1/lists/recently_updated/contacts/recent'; + const endpoint = '/contacts/v1/lists/recently_updated/contacts/recent'; if (returnAll) { responseData = await hubspotApiRequestAllItems.call( @@ -1427,8 +1425,7 @@ export class Hubspot implements INodeType { }; if (filtersGroupsUi) { - const filterGroupValues = (filtersGroupsUi as IDataObject) - .filterGroupsValues as IDataObject[]; + const filterGroupValues = filtersGroupsUi.filterGroupsValues as IDataObject[]; if (filterGroupValues) { body.filterGroups = []; for (const filterGroupValue of filterGroupValues) { @@ -2248,8 +2245,7 @@ export class Hubspot implements INodeType { }; if (filtersGroupsUi) { - const filterGroupValues = (filtersGroupsUi as IDataObject) - .filterGroupsValues as IDataObject[]; + const filterGroupValues = filtersGroupsUi.filterGroupsValues as IDataObject[]; if (filterGroupValues) { body.filterGroups = []; for (const filterGroupValue of filterGroupValues) { @@ -2412,10 +2408,10 @@ export class Hubspot implements INodeType { const consent: IDataObject = {}; if (legalConsent) { if (legalConsent.consentToProcess) { - consent!.consentToProcess = legalConsent.consentToProcess as boolean; + consent.consentToProcess = legalConsent.consentToProcess as boolean; } if (legalConsent.text) { - consent!.text = legalConsent.text as string; + consent.text = legalConsent.text as string; } if (legalConsent.communicationsUi) { consent.communications = (legalConsent.communicationsUi as IDataObject) diff --git a/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts b/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts index f3a42de481..9804a9cad6 100644 --- a/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts +++ b/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts @@ -315,8 +315,7 @@ export class HubspotTrigger implements INodeType { const webhookUrl = this.getNodeWebhookUrl('default'); const { appId } = await this.getCredentials('hubspotDeveloperApi'); const events = - (((this.getNodeParameter('eventsUi') as IDataObject) || {}) - .eventValues as IDataObject[]) || []; + ((this.getNodeParameter('eventsUi') as IDataObject)?.eventValues as IDataObject[]) || []; const additionalFields = this.getNodeParameter('additionalFields') as IDataObject; let endpoint = `/webhooks/v3/${appId}/settings`; let body: IDataObject = { @@ -390,7 +389,7 @@ export class HubspotTrigger implements INodeType { return {}; } - const hash = `${credentials!.clientSecret}${JSON.stringify(bodyData)}`; + const hash = `${credentials.clientSecret}${JSON.stringify(bodyData)}`; const signature = createHash('sha256').update(hash).digest('hex'); //@ts-ignore if (signature !== headerData['x-hubspot-signature']) { diff --git a/packages/nodes-base/nodes/HumanticAI/HumanticAi.node.ts b/packages/nodes-base/nodes/HumanticAI/HumanticAi.node.ts index 97a2e263a1..ac5cd3fa8d 100644 --- a/packages/nodes-base/nodes/HumanticAI/HumanticAi.node.ts +++ b/packages/nodes-base/nodes/HumanticAI/HumanticAi.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IBinaryKeyData, IDataObject, INodeExecutionData, @@ -81,7 +80,7 @@ export class HumanticAi implements INodeType { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryPropertyName] as IBinaryData; + const binaryData = item[binaryPropertyName]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); if (binaryData === undefined) { @@ -154,7 +153,7 @@ export class HumanticAi implements INodeType { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryPropertyName] as IBinaryData; + const binaryData = item[binaryPropertyName]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); if (binaryData === undefined) { diff --git a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts index f60010c5fc..8932a2f3cc 100644 --- a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts @@ -61,8 +61,7 @@ export async function hunterApiRequestAllItems( returnData.push(responseData[propertyName]); query.offset += query.limit; } while ( - responseData.meta !== undefined && - responseData.meta.results !== undefined && + responseData.meta?.results !== undefined && responseData.meta.offset <= responseData.meta.results ); return returnData; diff --git a/packages/nodes-base/nodes/Hunter/Hunter.node.ts b/packages/nodes-base/nodes/Hunter/Hunter.node.ts index 917f8ffd98..f684ae3936 100644 --- a/packages/nodes-base/nodes/Hunter/Hunter.node.ts +++ b/packages/nodes-base/nodes/Hunter/Hunter.node.ts @@ -304,17 +304,17 @@ export class Hunter implements INodeType { // Make sure that the company information is there only once and // the emails are combined underneath it. - if (onlyEmails === false) { + if (!onlyEmails) { let tempReturnData: IDataObject = {}; - for (let i = 0; i < responseData.length; i++) { - if (i === 0) { - tempReturnData = responseData[i]; + for (let index = 0; index < responseData.length; index++) { + if (index === 0) { + tempReturnData = responseData[index]; continue; } - ((tempReturnData as IDataObject).emails as IDataObject[]).push.apply( + (tempReturnData.emails as IDataObject[]).push.apply( tempReturnData.emails, - responseData[i].emails, + responseData[index].emails, ); } @@ -327,7 +327,7 @@ export class Hunter implements INodeType { responseData = responseData.data; } - if (onlyEmails === true) { + if (onlyEmails) { let tempReturnData: IDataObject[] = []; if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/ICalendar/ICalendar.node.ts b/packages/nodes-base/nodes/ICalendar/ICalendar.node.ts index 0dcf26242a..d86ca44ea8 100644 --- a/packages/nodes-base/nodes/ICalendar/ICalendar.node.ts +++ b/packages/nodes-base/nodes/ICalendar/ICalendar.node.ts @@ -307,7 +307,7 @@ export class ICalendar implements INodeType { const allDay = this.getNodeParameter('allDay', i) as boolean; const start = this.getNodeParameter('start', i) as string; let end = this.getNodeParameter('end', i) as string; - end = allDay ? (moment(end).utc().add(1, 'day').format() as string) : end; + end = allDay ? moment(end).utc().add(1, 'day').format() : end; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); let fileName = 'event.ics'; diff --git a/packages/nodes-base/nodes/If/If.node.ts b/packages/nodes-base/nodes/If/If.node.ts index 8668c7e8fd..03c0ee0c7a 100644 --- a/packages/nodes-base/nodes/If/If.node.ts +++ b/packages/nodes-base/nodes/If/If.node.ts @@ -456,12 +456,12 @@ export class If implements INodeType { value2, ); - if (compareOperationResult === true && combineOperation === 'any') { + if (compareOperationResult && combineOperation === 'any') { // If it passes and the operation is "any" we do not have to check any // other ones as it should pass anyway. So go on with the next item. returnDataTrue.push(item); continue itemLoop; - } else if (compareOperationResult === false && combineOperation === 'all') { + } else if (!compareOperationResult && combineOperation === 'all') { // If it fails and the operation is "all" we do not have to check any // other ones as it should be not pass anyway. So go on with the next item. returnDataFalse.push(item); diff --git a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts index 221244ec82..58a6b89868 100644 --- a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts @@ -66,11 +66,7 @@ export async function intercomApiRequestAllItems( responseData = await intercomApiRequest.call(this, endpoint, method, body, query, uri); uri = responseData.pages.next; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.pages !== undefined && - responseData.pages.next !== undefined && - responseData.pages.next !== null - ); + } 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 06d357e2eb..f78708e799 100644 --- a/packages/nodes-base/nodes/Intercom/Intercom.node.ts +++ b/packages/nodes-base/nodes/Intercom/Intercom.node.ts @@ -9,10 +9,10 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; -import { leadFields, leadOpeations } from './LeadDescription'; +import { leadFields, leadOperations } from './LeadDescription'; import { intercomApiRequest, intercomApiRequestAllItems, validateJSON } from './GenericFunctions'; import { IAvatar, ILead, ILeadCompany } from './LeadInterface'; -import { userFields, userOpeations } from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; import { IUser, IUserCompany } from './UserInterface'; import { companyFields, companyOperations } from './CompanyDescription'; import { ICompany } from './CompanyInteface'; @@ -64,8 +64,8 @@ export class Intercom implements INodeType { ], default: 'user', }, - ...leadOpeations, - ...userOpeations, + ...leadOperations, + ...userOperations, ...companyOperations, ...userFields, ...leadFields, @@ -79,13 +79,13 @@ export class Intercom implements INodeType { // select them easily async getCompanies(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - let companies, response; + let response; try { response = await intercomApiRequest.call(this, '/companies', 'GET'); } catch (error) { throw new NodeApiError(this.getNode(), error); } - companies = response.companies; + const companies = response.companies; for (const company of companies) { const companyName = company.name; const companyId = company.company_id; @@ -172,10 +172,10 @@ export class Intercom implements INodeType { ).customAttributesValues as IDataObject[]; if (customAttributesValues) { const customAttributes = {}; - for (let i = 0; i < customAttributesValues.length; i++) { + for (let index = 0; index < customAttributesValues.length; index++) { // @ts-ignore - customAttributes[customAttributesValues[i].name] = - customAttributesValues[i].value; + customAttributes[customAttributesValues[index].name] = + customAttributesValues[index].value; } body.custom_attributes = customAttributes; } @@ -234,7 +234,7 @@ export class Intercom implements INodeType { Object.assign(qs, filters); try { - if (returnAll === true) { + if (returnAll) { responseData = await intercomApiRequestAllItems.call( this, 'contacts', @@ -345,10 +345,10 @@ export class Intercom implements INodeType { ).customAttributesValues as IDataObject[]; if (customAttributesValues) { const customAttributes = {}; - for (let i = 0; i < customAttributesValues.length; i++) { + for (let index = 0; index < customAttributesValues.length; index++) { // @ts-ignore - customAttributes[customAttributesValues[i].name] = - customAttributesValues[i].value; + customAttributes[customAttributesValues[index].name] = + customAttributesValues[index].value; } body.custom_attributes = customAttributes; } @@ -409,7 +409,7 @@ export class Intercom implements INodeType { Object.assign(qs, filters); try { - if (returnAll === true) { + if (returnAll) { responseData = await intercomApiRequestAllItems.call( this, 'users', @@ -473,10 +473,10 @@ export class Intercom implements INodeType { ).customAttributesValues as IDataObject[]; if (customAttributesValues) { const customAttributes = {}; - for (let i = 0; i < customAttributesValues.length; i++) { + for (let index = 0; index < customAttributesValues.length; index++) { // @ts-ignore - customAttributes[customAttributesValues[i].name] = - customAttributesValues[i].value; + customAttributes[customAttributesValues[index].name] = + customAttributesValues[index].value; } body.custom_attributes = customAttributes; } @@ -533,7 +533,7 @@ export class Intercom implements INodeType { Object.assign(qs, filters); try { - if (returnAll === true) { + if (returnAll) { responseData = await intercomApiRequestAllItems.call( this, 'companies', @@ -566,7 +566,7 @@ export class Intercom implements INodeType { try { if (listBy === 'id') { - if (returnAll === true) { + if (returnAll) { responseData = await intercomApiRequestAllItems.call( this, 'users', @@ -589,7 +589,7 @@ export class Intercom implements INodeType { } else { qs.type = 'users'; - if (returnAll === true) { + if (returnAll) { responseData = await intercomApiRequestAllItems.call( this, 'users', diff --git a/packages/nodes-base/nodes/Intercom/LeadDescription.ts b/packages/nodes-base/nodes/Intercom/LeadDescription.ts index a03a5d8bea..628f8495fd 100644 --- a/packages/nodes-base/nodes/Intercom/LeadDescription.ts +++ b/packages/nodes-base/nodes/Intercom/LeadDescription.ts @@ -1,6 +1,6 @@ import { INodeProperties } from 'n8n-workflow'; -export const leadOpeations: INodeProperties[] = [ +export const leadOperations: INodeProperties[] = [ { displayName: 'Operation', name: 'operation', diff --git a/packages/nodes-base/nodes/Intercom/UserDescription.ts b/packages/nodes-base/nodes/Intercom/UserDescription.ts index 5f2a4a2281..a267e8d0f4 100644 --- a/packages/nodes-base/nodes/Intercom/UserDescription.ts +++ b/packages/nodes-base/nodes/Intercom/UserDescription.ts @@ -1,6 +1,6 @@ import { INodeProperties } from 'n8n-workflow'; -export const userOpeations: INodeProperties[] = [ +export const userOperations: INodeProperties[] = [ { displayName: 'Operation', name: 'operation', diff --git a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts index d697232cf7..3f8efa2e13 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts @@ -36,7 +36,7 @@ export async function invoiceNinjaApiRequest( const version = this.getNodeParameter('apiVersion', 0) as string; const defaultUrl = version === 'v4' ? 'https://app.invoiceninja.com' : 'https://invoicing.co'; - const baseUrl = credentials!.url || defaultUrl; + const baseUrl = credentials.url || defaultUrl; const options: OptionsWithUri = { method, @@ -74,12 +74,7 @@ export async function invoiceNinjaApiRequestAllItems( uri = next; } returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.meta !== undefined && - responseData.meta.pagination && - responseData.meta.pagination.links && - responseData.meta.pagination.links.next - ); + } 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 487ed59dab..7ecea8bace 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts @@ -368,7 +368,7 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - if (returnAll === true) { + if (returnAll) { responseData = await invoiceNinjaApiRequestAllItems.call( this, 'data', @@ -466,7 +466,7 @@ export class InvoiceNinja implements INodeType { const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject) .invoiceItemsValues as IDataObject[]; if (invoceItemsValues) { - const items: IItem[] = []; + const invoiceItems: IItem[] = []; for (const itemValue of invoceItemsValues) { const item: IItem = { cost: itemValue.cost as number, @@ -478,9 +478,9 @@ export class InvoiceNinja implements INodeType { tax_name1: itemValue.taxName1 as string, tax_name2: itemValue.taxName2 as string, }; - items.push(item); + invoiceItems.push(item); } - body.invoice_items = items; + body.invoice_items = invoiceItems; } responseData = await invoiceNinjaApiRequest.call( this, @@ -529,7 +529,7 @@ export class InvoiceNinja implements INodeType { if (options.invoiceNumber) { qs.invoice_number = options.invoiceNumber as string; } - if (returnAll === true) { + if (returnAll) { responseData = await invoiceNinjaApiRequestAllItems.call( this, 'data', @@ -581,15 +581,15 @@ export class InvoiceNinja implements INodeType { let from = 0, to; if (logValue.startDate) { - from = (new Date(logValue.startDate as string).getTime() / 1000) as number; + from = new Date(logValue.startDate as string).getTime() / 1000; } if (logValue.endDate) { - to = (new Date(logValue.endDate as string).getTime() / 1000) as number; + to = new Date(logValue.endDate as string).getTime() / 1000; } if (logValue.duration) { to = from + (logValue.duration as number) * 3600; } - logs.push([from as number, to as number]); + logs.push([from, to as number]); } body.time_log = JSON.stringify(logs); } @@ -622,7 +622,7 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - if (returnAll === true) { + if (returnAll) { responseData = await invoiceNinjaApiRequestAllItems.call( this, 'data', @@ -694,7 +694,7 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - if (returnAll === true) { + if (returnAll) { responseData = await invoiceNinjaApiRequestAllItems.call( this, 'data', @@ -795,7 +795,7 @@ export class InvoiceNinja implements INodeType { } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === true) { + if (returnAll) { responseData = await invoiceNinjaApiRequestAllItems.call( this, 'data', @@ -896,7 +896,7 @@ export class InvoiceNinja implements INodeType { const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject) .invoiceItemsValues as IDataObject[]; if (invoceItemsValues) { - const items: IItem[] = []; + const invoiceItems: IItem[] = []; for (const itemValue of invoceItemsValues) { const item: IItem = { cost: itemValue.cost as number, @@ -908,9 +908,9 @@ export class InvoiceNinja implements INodeType { tax_name1: itemValue.taxName1 as string, tax_name2: itemValue.taxName2 as string, }; - items.push(item); + invoiceItems.push(item); } - body.invoice_items = items; + body.invoice_items = invoiceItems; } responseData = await invoiceNinjaApiRequest.call( this, @@ -959,7 +959,7 @@ export class InvoiceNinja implements INodeType { if (options.invoiceNumber) { qs.invoice_number = options.invoiceNumber as string; } - if (returnAll === true) { + if (returnAll) { responseData = await invoiceNinjaApiRequestAllItems.call( this, 'data', diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts index 9eff070a9b..3cb8f66f8d 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts @@ -1,6 +1,6 @@ import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; +import { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; import { eventID, @@ -126,12 +126,12 @@ export class InvoiceNinjaTrigger implements INodeType { } if (apiVersion === 'v5') { - const registeredWebhooks = (await invoiceNinjaApiRequestAllItems.call( + const registeredWebhooks = await invoiceNinjaApiRequestAllItems.call( this, 'data', 'GET', '/webhooks', - )) as IDataObject[]; + ); for (const webhook of registeredWebhooks) { if ( diff --git a/packages/nodes-base/nodes/ItemLists/ItemLists.node.ts b/packages/nodes-base/nodes/ItemLists/ItemLists.node.ts index 81821c8345..65db51ee55 100644 --- a/packages/nodes-base/nodes/ItemLists/ItemLists.node.ts +++ b/packages/nodes-base/nodes/ItemLists/ItemLists.node.ts @@ -755,14 +755,14 @@ return 0;`, const include = this.getNodeParameter('include', i) as string; let arrayToSplit; - if (disableDotNotation === false) { + if (!disableDotNotation) { arrayToSplit = get(items[i].json, fieldToSplitOut); } else { - arrayToSplit = items[i].json[fieldToSplitOut as string]; + arrayToSplit = items[i].json[fieldToSplitOut]; } if (arrayToSplit === undefined) { - if (fieldToSplitOut.includes('.') && disableDotNotation === true) { + if (fieldToSplitOut.includes('.') && disableDotNotation) { throw new NodeOperationError( this.getNode(), `Couldn't find the field '${fieldToSplitOut}' in the input data`, @@ -806,12 +806,12 @@ return 0;`, return prev; } let value; - if (disableDotNotation === false) { + if (!disableDotNotation) { value = get(items[i].json, field); } else { - value = items[i].json[field as string]; + value = items[i].json[field]; } - prev = { ...prev, [field as string]: value }; + prev = { ...prev, [field]: value }; return prev; }, {}), }; @@ -821,12 +821,12 @@ return 0;`, newItem = { ...keys.reduce((prev, field) => { let value; - if (disableDotNotation === false) { + if (!disableDotNotation) { value = get(items[i].json, field); } else { - value = items[i].json[field as string]; + value = items[i].json[field]; } - prev = { ...prev, [field as string]: value }; + prev = { ...prev, [field]: value }; return prev; }, {}), }; @@ -843,7 +843,7 @@ return 0;`, } else { newItem = { ...newItem, - [(destinationFieldName as string) || (fieldToSplitOut as string)]: element, + [destinationFieldName || fieldToSplitOut]: element, }; } @@ -888,7 +888,7 @@ return 0;`, description: 'Please add a field to aggregate', }); } - if (disableDotNotation === false) { + if (!disableDotNotation) { if (get(item.json, fieldToAggregate) !== undefined) { found = true; } @@ -896,7 +896,7 @@ return 0;`, found = true; } } - if (found === false && disableDotNotation && fieldToAggregate.includes('.')) { + if (!found && disableDotNotation && fieldToAggregate.includes('.')) { throw new NodeOperationError( this.getNode(), `Couldn't find the field '${fieldToAggregate}' in the input data`, @@ -904,7 +904,7 @@ return 0;`, description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options`, }, ); - } else if (found === false && keepMissing === false) { + } else if (!found && !keepMissing) { throw new NodeOperationError( this.getNode(), `Couldn't find the field '${fieldToAggregate}' in the input data`, @@ -912,8 +912,7 @@ return 0;`, } } - let newItem: INodeExecutionData; - newItem = { + const newItem: INodeExecutionData = { json: {}, pairedItem: Array.from({ length }, (_, i) => i).map((index) => { return { @@ -939,7 +938,7 @@ return 0;`, } const getFieldToAggregate = () => - disableDotNotation === false && fieldToAggregate.includes('.') + !disableDotNotation && fieldToAggregate.includes('.') ? fieldToAggregate.split('.').pop() : fieldToAggregate; @@ -950,12 +949,12 @@ return 0;`, if (fieldToAggregate !== '') { values[_outputFieldName] = []; for (let i = 0; i < length; i++) { - if (disableDotNotation === false) { + if (!disableDotNotation) { let value = get(items[i].json, fieldToAggregate); if (!keepMissing) { if (Array.isArray(value)) { - value = value.filter((value) => value !== null); + value = value.filter((entry) => entry !== null); } else if (value === null || value === undefined) { continue; } @@ -971,7 +970,7 @@ return 0;`, if (!keepMissing) { if (Array.isArray(value)) { - value = value.filter((value) => value !== null); + value = value.filter((entry) => entry !== null); } else if (value === null || value === undefined) { continue; } @@ -988,7 +987,7 @@ return 0;`, } for (const key of Object.keys(values)) { - if (disableDotNotation === false) { + if (!disableDotNotation) { set(newItem.json, key, values[key]); } else { newItem.json[key] = values[key]; @@ -1074,7 +1073,7 @@ return 0;`, 'No fields specified. Please add a field to exclude from comparison', ); } - if (disableDotNotation === false) { + if (!disableDotNotation) { keys = Object.keys(flattenKeys(items[0].json)); } keys = keys.filter((key) => !fieldsToExclude.includes(key)); @@ -1089,7 +1088,7 @@ return 0;`, 'No fields specified. Please add a field to compare on', ); } - if (disableDotNotation === false) { + if (!disableDotNotation) { keys = Object.keys(flattenKeys(items[0].json)); } keys = fieldsToCompare.map((key) => key.trim()); @@ -1100,7 +1099,7 @@ return 0;`, const newItems = items.map( (item, index) => ({ - json: { ...item['json'], __INDEX: index }, + json: { ...item.json, __INDEX: index }, pairedItem: { item: index }, } as INodeExecutionData), ); @@ -1110,14 +1109,14 @@ return 0;`, for (const key of keys) { let equal; - if (disableDotNotation === false) { + if (!disableDotNotation) { equal = isEqual(get(a.json, key), get(b.json, key)); } else { equal = isEqual(a.json[key], b.json[key]); } if (!equal) { let lessThan; - if (disableDotNotation === false) { + if (!disableDotNotation) { lessThan = lt(get(a.json, key), get(b.json, key)); } else { lessThan = lt(a.json[key], b.json[key]); @@ -1203,7 +1202,7 @@ return 0;`, order: 'ascending' | 'descending'; }>; - if (!sortFields || !sortFields.length) { + if (!sortFields?.length) { throw new NodeOperationError( this.getNode(), 'No sorting specified. Please add a field to sort by', @@ -1213,7 +1212,7 @@ return 0;`, for (const { fieldName } of sortFields) { let found = false; for (const item of items) { - if (disableDotNotation === false) { + if (!disableDotNotation) { if (get(item.json, fieldName) !== undefined) { found = true; } @@ -1221,7 +1220,7 @@ return 0;`, found = true; } } - if (found === false && disableDotNotation && fieldName.includes('.')) { + if (!found && disableDotNotation && fieldName.includes('.')) { throw new NodeOperationError( this.getNode(), `Couldn't find the field '${fieldName}' in the input data`, @@ -1229,7 +1228,7 @@ return 0;`, description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options`, }, ); - } else if (found === false) { + } else if (!found) { throw new NodeOperationError( this.getNode(), `Couldn't find the field '${fieldName}' in the input data`, @@ -1246,7 +1245,7 @@ return 0;`, let result = 0; for (const field of sortFieldsWithDirection) { let equal; - if (disableDotNotation === false) { + if (!disableDotNotation) { const _a = typeof get(a.json, field.name) === 'string' ? (get(a.json, field.name) as string).toLowerCase() @@ -1258,19 +1257,19 @@ return 0;`, equal = isEqual(_a, _b); } else { const _a = - typeof a.json[field.name as string] === 'string' - ? (a.json[field.name as string] as string).toLowerCase() - : a.json[field.name as string]; + typeof a.json[field.name] === 'string' + ? (a.json[field.name] as string).toLowerCase() + : a.json[field.name]; const _b = - typeof b.json[field.name as string] === 'string' - ? (b.json[field.name as string] as string).toLowerCase() - : b.json[field.name as string]; + typeof b.json[field.name] === 'string' + ? (b.json[field.name] as string).toLowerCase() + : b.json[field.name]; equal = isEqual(_a, _b); } if (!equal) { let lessThan; - if (disableDotNotation === false) { + if (!disableDotNotation) { const _a = typeof get(a.json, field.name) === 'string' ? (get(a.json, field.name) as string).toLowerCase() @@ -1282,13 +1281,13 @@ return 0;`, lessThan = lt(_a, _b); } else { const _a = - typeof a.json[field.name as string] === 'string' - ? (a.json[field.name as string] as string).toLowerCase() - : a.json[field.name as string]; + typeof a.json[field.name] === 'string' + ? (a.json[field.name] as string).toLowerCase() + : a.json[field.name]; const _b = - typeof b.json[field.name as string] === 'string' - ? (b.json[field.name as string] as string).toLowerCase() - : b.json[field.name as string]; + typeof b.json[field.name] === 'string' + ? (b.json[field.name] as string).toLowerCase() + : b.json[field.name]; lessThan = lt(_a, _b); } if (lessThan) { @@ -1305,7 +1304,7 @@ return 0;`, const code = this.getNodeParameter('code', 0) as string; const regexCheck = /\breturn\b/g.exec(code); - if (regexCheck && regexCheck.length) { + if (regexCheck?.length) { const sandbox = { newItems, }; @@ -1367,13 +1366,13 @@ const compareItems = ( ) => { let result = true; for (const key of keys) { - if (disableDotNotation === false) { + if (!disableDotNotation) { if (!isEqual(get(obj.json, key), get(obj2.json, key))) { result = false; break; } } else { - if (!isEqual(obj.json[key as string], obj2.json[key as string])) { + if (!isEqual(obj.json[key], obj2.json[key])) { result = false; break; } @@ -1382,10 +1381,10 @@ const compareItems = ( return result; }; -const flattenKeys = (obj: {}, path: string[] = []): {} => { +const flattenKeys = (obj: IDataObject, path: string[] = []): IDataObject => { return !isObject(obj) ? { [path.join('.')]: obj } - : reduce(obj, (cum, next, key) => merge(cum, flattenKeys(next, [...path, key])), {}); + : reduce(obj, (cum, next, key) => merge(cum, flattenKeys(next as IDataObject, [...path, key])), {}); //prettier-ignore }; const shuffleArray = (array: any[]) => { diff --git a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts index f073aa9f33..ba327f37c6 100644 --- a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts @@ -57,9 +57,9 @@ export async function iterableApiRequestAllItems( do { responseData = await iterableApiRequest.call(this, method, endpoint, body, query); - query.pageToken = responseData['nextPageToken']; + query.pageToken = responseData.nextPageToken; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); + } 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 4b8755ffb2..073f77906e 100644 --- a/packages/nodes-base/nodes/Iterable/Iterable.node.ts +++ b/packages/nodes-base/nodes/Iterable/Iterable.node.ts @@ -180,7 +180,7 @@ export class Iterable implements INodeType { responseData = await iterableApiRequest.call(this, 'POST', '/users/update', body); - if (this.continueOnFail() === false) { + if (!this.continueOnFail()) { if (responseData.code !== 'Success') { throw new NodeOperationError( this.getNode(), @@ -212,7 +212,7 @@ export class Iterable implements INodeType { responseData = await iterableApiRequest.call(this, 'DELETE', endpoint); - if (this.continueOnFail() === false) { + if (!this.continueOnFail()) { if (responseData.code !== 'Success') { throw new NodeApiError(this.getNode(), responseData); } @@ -241,7 +241,7 @@ export class Iterable implements INodeType { responseData = await iterableApiRequest.call(this, 'GET', endpoint, {}, qs); - if (this.continueOnFail() === false) { + if (!this.continueOnFail()) { if (Object.keys(responseData).length === 0) { throw new NodeApiError(this.getNode(), responseData, { message: `User not found`, diff --git a/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts b/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts index 8baeaffb3d..a7015cc95c 100644 --- a/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts +++ b/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts @@ -501,9 +501,9 @@ export class Jenkins implements INodeType { if (operation === 'triggerParams') { const job = this.getNodeParameter('job', i) as string; const params = this.getNodeParameter('param.params', i, []) as []; - let body = {}; + let form = {}; if (params.length) { - body = params.reduce((body: IDataObject, param: { name: string; value: string }) => { + form = params.reduce((body: IDataObject, param: { name: string; value: string }) => { body[param.name] = param.value; return body; }, {}); @@ -516,7 +516,7 @@ export class Jenkins implements INodeType { {}, {}, { - form: body, + form, headers: { 'content-type': 'application/x-www-form-urlencoded', }, diff --git a/packages/nodes-base/nodes/Jira/Jira.node.ts b/packages/nodes-base/nodes/Jira/Jira.node.ts index fbe509a3b7..b70b503b87 100644 --- a/packages/nodes-base/nodes/Jira/Jira.node.ts +++ b/packages/nodes-base/nodes/Jira/Jira.node.ts @@ -3,7 +3,6 @@ import { mergeWith } from 'lodash'; import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IBinaryKeyData, IDataObject, ILoadOptionsFunctions, @@ -738,7 +737,7 @@ export class Jira implements INodeType { const options = this.getNodeParameter('options', i); const body: IDataObject = {}; if (options.fields) { - body.fields = (options.fields as string).split(',') as string[]; + body.fields = (options.fields as string).split(','); } if (options.jql) { body.jql = options.jql as string; @@ -815,7 +814,7 @@ export class Jira implements INodeType { for (let i = 0; i < length; i++) { const issueKey = this.getNodeParameter('issueKey', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); - const jsonActive = this.getNodeParameter('jsonParameters', 0) as boolean; + const jsonActive = this.getNodeParameter('jsonParameters', 0); const body: INotify = {}; if (additionalFields.textBody) { body.textBody = additionalFields.textBody as string; @@ -987,7 +986,7 @@ export class Jira implements INodeType { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryPropertyName] as IBinaryData; + const binaryData = item[binaryPropertyName]; const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); if (binaryData === undefined) { @@ -1068,7 +1067,7 @@ export class Jira implements INodeType { if (download) { const binaryPropertyName = this.getNodeParameter('binaryProperty', 0); for (const [index, attachment] of returnData.entries()) { - returnData[index]['binary'] = {}; + returnData[index].binary = {}; const buffer = await jiraSoftwareCloudApiRequest.call( this, @@ -1077,11 +1076,11 @@ export class Jira implements INodeType { {}, {}, // @ts-ignore - attachment?.json!.content, + attachment?.json.content, { json: false, encoding: null }, ); //@ts-ignore - returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData( + returnData[index].binary[binaryPropertyName] = await this.helpers.prepareBinaryData( buffer, // @ts-ignore attachment.json.filename, @@ -1106,7 +1105,7 @@ export class Jira implements INodeType { qs, ); responseData = attachment; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.slice(0, limit); } @@ -1122,7 +1121,7 @@ export class Jira implements INodeType { if (download) { const binaryPropertyName = this.getNodeParameter('binaryProperty', 0); for (const [index, attachment] of returnData.entries()) { - returnData[index]['binary'] = {}; + returnData[index].binary = {}; //@ts-ignore const buffer = await jiraSoftwareCloudApiRequest.call( this, @@ -1135,7 +1134,7 @@ export class Jira implements INodeType { { json: false, encoding: null }, ); //@ts-ignore - returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData( + returnData[index].binary[binaryPropertyName] = await this.helpers.prepareBinaryData( buffer, // @ts-ignore attachment.json.filename, @@ -1153,7 +1152,7 @@ export class Jira implements INodeType { //https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post if (operation === 'add') { for (let i = 0; i < length; i++) { - const jsonParameters = this.getNodeParameter('jsonParameters', 0) as boolean; + const jsonParameters = this.getNodeParameter('jsonParameters', 0); const issueKey = this.getNodeParameter('issueKey', i) as string; const options = this.getNodeParameter('options', i); const body: IDataObject = {}; @@ -1163,7 +1162,7 @@ export class Jira implements INodeType { } Object.assign(body, options); - if (jsonParameters === false) { + if (!jsonParameters) { const comment = this.getNodeParameter('comment', i) as string; if (jiraVersion === 'server') { Object.assign(body, { body: comment }); @@ -1302,14 +1301,14 @@ export class Jira implements INodeType { const issueKey = this.getNodeParameter('issueKey', i) as string; const commentId = this.getNodeParameter('commentId', i) as string; const options = this.getNodeParameter('options', i); - const jsonParameters = this.getNodeParameter('jsonParameters', 0) as boolean; + const jsonParameters = this.getNodeParameter('jsonParameters', 0); const body: IDataObject = {}; if (options.expand) { qs.expand = options.expand as string; delete options.expand; } Object.assign(qs, options); - if (jsonParameters === false) { + if (!jsonParameters) { const comment = this.getNodeParameter('comment', i) as string; if (jiraVersion === 'server') { Object.assign(body, { body: comment }); diff --git a/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts b/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts index e71d3a342d..0b97e28897 100644 --- a/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts +++ b/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts @@ -101,6 +101,7 @@ export class JotFormTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { @@ -171,8 +172,8 @@ export class JotFormTrigger implements INodeType { data.rawRequest = rawRequest; let returnData: IDataObject; - if (resolveData === false) { - if (onlyAnswers === true) { + if (!resolveData) { + if (onlyAnswers) { returnData = data.rawRequest as unknown as IDataObject; } else { returnData = data; @@ -189,7 +190,7 @@ export class JotFormTrigger implements INodeType { // Create a dictionary to resolve the keys const questionNames: IDataObject = {}; - for (const question of Object.values(responseData.content) as IQuestionData[]) { + for (const question of Object.values(responseData.content)) { questionNames[question.name] = question.text; } @@ -209,7 +210,7 @@ export class JotFormTrigger implements INodeType { questionsData[questionNames[questionKey] as string] = rawRequest[key]; } - if (onlyAnswers === true) { + if (onlyAnswers) { returnData = questionsData as unknown as IDataObject; } else { // @ts-ignore diff --git a/packages/nodes-base/nodes/Kafka/Kafka.node.ts b/packages/nodes-base/nodes/Kafka/Kafka.node.ts index 197cd53f0c..c058195da6 100644 --- a/packages/nodes-base/nodes/Kafka/Kafka.node.ts +++ b/packages/nodes-base/nodes/Kafka/Kafka.node.ts @@ -221,7 +221,7 @@ export class Kafka implements INodeType { try { const brokers = ((credentials.brokers as string) || '') .split(',') - .map((item) => item.trim()) as string[]; + .map((item) => item.trim()); const clientId = credentials.clientId as string; @@ -271,7 +271,7 @@ export class Kafka implements INodeType { let responseData: IDataObject[]; try { - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); const sendInputData = this.getNodeParameter('sendInputData', 0) as boolean; const useSchemaRegistry = this.getNodeParameter('useSchemaRegistry', 0) as boolean; @@ -288,9 +288,7 @@ export class Kafka implements INodeType { const credentials = await this.getCredentials('kafka'); - const brokers = ((credentials.brokers as string) || '') - .split(',') - .map((item) => item.trim()) as string[]; + const brokers = ((credentials.brokers as string) || '').split(',').map((item) => item.trim()); const clientId = credentials.clientId as string; @@ -325,7 +323,7 @@ export class Kafka implements INodeType { let message: string | Buffer; for (let i = 0; i < length; i++) { - if (sendInputData === true) { + if (sendInputData) { message = JSON.stringify(items[i].json); } else { message = this.getNodeParameter('message', i) as string; @@ -358,7 +356,7 @@ export class Kafka implements INodeType { let headers; - if (jsonParameters === true) { + if (jsonParameters) { headers = this.getNodeParameter('headerParametersJson', i) as string; try { headers = JSON.parse(headers); diff --git a/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts b/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts index dcde8ca63a..676f1551c8 100644 --- a/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts +++ b/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts @@ -171,9 +171,7 @@ export class KafkaTrigger implements INodeType { const credentials = await this.getCredentials('kafka'); - const brokers = ((credentials.brokers as string) || '') - .split(',') - .map((item) => item.trim()) as string[]; + const brokers = ((credentials.brokers as string) || '').split(',').map((item) => item.trim()); const clientId = credentials.clientId as string; @@ -231,7 +229,7 @@ export class KafkaTrigger implements INodeType { await consumer.run({ autoCommitInterval: (options.autoCommitInterval as number) || null, autoCommitThreshold: (options.autoCommitThreshold as number) || null, - eachMessage: async ({ topic, message }) => { + eachMessage: async ({ topic: messageTopic, message }) => { let data: IDataObject = {}; let value = message.value?.toString() as string; @@ -259,7 +257,7 @@ export class KafkaTrigger implements INodeType { } data.message = value; - data.topic = topic; + data.topic = messageTopic; if (options.onlyMessage) { //@ts-ignore @@ -271,7 +269,7 @@ export class KafkaTrigger implements INodeType { }); }; - startConsumer(); + await startConsumer(); // The "closeFunction" function gets called by n8n whenever // the workflow gets deactivated and can so clean up. @@ -286,7 +284,7 @@ export class KafkaTrigger implements INodeType { // would trigger by itself so that the user knows what data // to expect. async function manualTriggerFunction() { - startConsumer(); + await startConsumer(); } return { diff --git a/packages/nodes-base/nodes/Keap/Keap.node.ts b/packages/nodes-base/nodes/Keap/Keap.node.ts index 6e4f4def5b..35a87c85bd 100644 --- a/packages/nodes-base/nodes/Keap/Keap.node.ts +++ b/packages/nodes-base/nodes/Keap/Keap.node.ts @@ -186,7 +186,7 @@ export class Keap implements INodeType { const countryId = key; returnData.push({ name: countryName as string, - value: countryId as string, + value: countryId, }); } return returnData; @@ -206,7 +206,7 @@ export class Keap implements INodeType { const provinceId = key; returnData.push({ name: provinceName as string, - value: provinceId as string, + value: provinceId, }); } return returnData; @@ -590,9 +590,7 @@ export class Keap implements INodeType { order_type: pascalCase(orderType), }; if (additionalFields.promoCodes) { - additionalFields.promoCodes = (additionalFields.promoCodes as string).split( - ',', - ) as string[]; + additionalFields.promoCodes = (additionalFields.promoCodes as string).split(','); } keysToSnakeCase(additionalFields); Object.assign(body, additionalFields); @@ -691,7 +689,7 @@ export class Keap implements INodeType { sent_from_address: sentFromAddress, }; Object.assign(body, additionalFields); - keysToSnakeCase(body as IDataObject); + keysToSnakeCase(body); responseData = await keapApiRequest.call(this, 'POST', '/emails', body); } //https://developer.infusionsoft.com/docs/rest/#!/Email/deleteEmailUsingDELETE @@ -724,9 +722,9 @@ export class Keap implements INodeType { //https://developer.infusionsoft.com/docs/rest/#!/Email/deleteEmailUsingDELETE if (operation === 'send') { const userId = this.getNodeParameter('userId', i) as number; - const contactIds = ( - (this.getNodeParameter('contactIds', i) as string).split(',') as string[] - ).map((e) => parseInt(e, 10)); + const contactIds = (this.getNodeParameter('contactIds', i) as string) + .split(',') + .map((e) => parseInt(e, 10)); const subject = this.getNodeParameter('subject', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); const body: IEmail = { @@ -839,7 +837,7 @@ export class Keap implements INodeType { const item = items[i].binary as IBinaryKeyData; - if (item[binaryPropertyName as string] === undefined) { + if (item[binaryPropertyName] === undefined) { throw new NodeOperationError( this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, @@ -847,8 +845,8 @@ export class Keap implements INodeType { ); } - body.file_data = item[binaryPropertyName as string].data; - body.file_name = item[binaryPropertyName as string].fileName; + body.file_data = item[binaryPropertyName].data; + body.file_name = item[binaryPropertyName].fileName; } else { const fileName = this.getNodeParameter('fileName', i) as string; const fileData = this.getNodeParameter('fileData', i) as string; diff --git a/packages/nodes-base/nodes/Keap/KeapTrigger.node.ts b/packages/nodes-base/nodes/Keap/KeapTrigger.node.ts index 5b6f3b5071..346b8aad58 100644 --- a/packages/nodes-base/nodes/Keap/KeapTrigger.node.ts +++ b/packages/nodes-base/nodes/Keap/KeapTrigger.node.ts @@ -153,7 +153,7 @@ export class KeapTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const rawData = this.getNodeParameter('rawData') as boolean; const headers = this.getHeaderData() as IDataObject; - const bodyData = this.getBodyData() as IDataObject; + const bodyData = this.getBodyData(); if (headers['x-hook-secret']) { // Is a create webhook confirmation request diff --git a/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts b/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts index 8a2d158631..794f0b4c90 100644 --- a/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts @@ -36,7 +36,7 @@ export async function kitemakerRequestAllItems( const resource = this.getNodeParameter('resource', 0) as 'space' | 'user' | 'workItem'; const [group, items] = getGroupAndItems(resource); - const returnAll = this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll = this.getNodeParameter('returnAll', 0, false); const limit = this.getNodeParameter('limit', 0, 0); const returnData: IDataObject[] = []; @@ -62,7 +62,7 @@ function getGroupAndItems(resource: 'space' | 'user' | 'workItem') { workItem: { group: 'workItems', items: 'workItems' }, }; - return [map[resource]['group'], map[resource]['items']]; + return [map[resource].group, map[resource].items]; } export function createLoadOptions( diff --git a/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts b/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts index 95eb2dfa2b..de39154965 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts @@ -191,8 +191,9 @@ export async function downloadAttachments( const credentials = await this.getCredentials('koBoToolboxApi'); // Look for attachment links - there can be more than one - const attachmentList = (submission['_attachments'] || submission['attachments']) as any[]; - if (attachmentList && attachmentList.length) { + const attachmentList = (submission._attachments || submission.attachments) as any[]; // tslint:disable-line:no-any + + if (attachmentList?.length) { for (const [index, attachment] of attachmentList.entries()) { // look for the question name linked to this attachment const fileName = attachment.filename; @@ -237,7 +238,7 @@ export async function downloadAttachments( while (!final && redir < 5) { response = await this.helpers.httpRequest(axiosOptions); - if (response && response.headers.location) { + if (response?.headers.location) { // Follow redirect axiosOptions.url = response.headers.location; redir++; @@ -246,7 +247,7 @@ export async function downloadAttachments( } } - if (response && response.body) { + if (response?.body) { // Use the provided prefix if any, otherwise try to use the original question name let binaryName; if ('question' === options.binaryNamingScheme && relatedQuestion) { diff --git a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts index 2754938096..1d47179c1a 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts @@ -126,7 +126,7 @@ export class KoBoToolbox implements INodeType { formQueryOptions?.sort?.value?.ordering, }), }, - scroll: this.getNodeParameter('returnAll', i) as boolean, + scroll: this.getNodeParameter('returnAll', i), }); } } @@ -154,7 +154,7 @@ export class KoBoToolbox implements INodeType { fields: JSON.stringify(parseStringList(submissionQueryOptions.fields as string)), }), }, - scroll: this.getNodeParameter('returnAll', i) as boolean, + scroll: this.getNodeParameter('returnAll', i), }); if (submissionQueryOptions.reformat) { @@ -278,7 +278,7 @@ export class KoBoToolbox implements INodeType { qs: { limit: this.getNodeParameter('limit', i, 1000), }, - scroll: this.getNodeParameter('returnAll', i) as boolean, + scroll: this.getNodeParameter('returnAll', i), }); } diff --git a/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts b/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts index 21cb2a102d..3198d6345e 100644 --- a/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts +++ b/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts @@ -134,7 +134,7 @@ export class Lemlist implements INodeType { responseData = await lemlistApiRequest.call(this, 'GET', '/activities', {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.slice(0, limit); } diff --git a/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts b/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts index 05c16c57f1..e71d45d34c 100644 --- a/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts +++ b/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts @@ -88,6 +88,7 @@ export class LemlistTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/Linear/GenericFunctions.ts b/packages/nodes-base/nodes/Linear/GenericFunctions.ts index 5b76687d25..a2fdb58434 100644 --- a/packages/nodes-base/nodes/Linear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Linear/GenericFunctions.ts @@ -38,7 +38,7 @@ export async function linearApiRequest( }; options = Object.assign({}, options, option); try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (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 0933237972..96b3cbd338 100644 --- a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts +++ b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts @@ -189,8 +189,6 @@ export class LinkedIn implements INodeType { }, }; } else if (shareMediaCategory === 'ARTICLE') { - const additionalFields = this.getNodeParameter('additionalFields', i); - if (additionalFields.description) { description = additionalFields.description as string; } diff --git a/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts b/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts index 2288bc01e0..893535ed8d 100644 --- a/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts +++ b/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts @@ -192,15 +192,15 @@ export class LocalFileTrigger implements INodeType { : (options.depth as number), }); - const executeTrigger = (event: string, path: string) => { - this.emit([this.helpers.returnJsonArray([{ event, path }])]); + const executeTrigger = (event: string, pathString: string) => { + this.emit([this.helpers.returnJsonArray([{ event, path: pathString }])]); }; for (const eventName of events) { - watcher.on(eventName, (path) => executeTrigger(eventName, path)); + watcher.on(eventName, (pathString) => executeTrigger(eventName, pathString)); } - function closeFunction() { + async function closeFunction() { return watcher.close(); } diff --git a/packages/nodes-base/nodes/MQTT/Mqtt.node.ts b/packages/nodes-base/nodes/MQTT/Mqtt.node.ts index 5b369344c2..fb1feba452 100644 --- a/packages/nodes-base/nodes/MQTT/Mqtt.node.ts +++ b/packages/nodes-base/nodes/MQTT/Mqtt.node.ts @@ -12,8 +12,6 @@ import { import mqtt from 'mqtt'; -import { IClientOptions } from 'mqtt'; - export class Mqtt implements INodeType { description: INodeTypeDescription = { displayName: 'MQTT', @@ -128,8 +126,8 @@ export class Mqtt implements INodeType { let client: mqtt.MqttClient; - if (ssl === false) { - const clientOptions: IClientOptions = { + if (!ssl) { + const clientOptions: mqtt.IClientOptions = { port, clean, clientId, @@ -141,7 +139,7 @@ export class Mqtt implements INodeType { } client = mqtt.connect(brokerUrl, clientOptions); } else { - const clientOptions: IClientOptions = { + const clientOptions: mqtt.IClientOptions = { port, clean, clientId, @@ -202,8 +200,8 @@ export class Mqtt implements INodeType { let client: mqtt.MqttClient; - if (ssl === false) { - const clientOptions: IClientOptions = { + if (!ssl) { + const clientOptions: mqtt.IClientOptions = { port, clean, clientId, @@ -216,7 +214,7 @@ export class Mqtt implements INodeType { client = mqtt.connect(brokerUrl, clientOptions); } else { - const clientOptions: IClientOptions = { + const clientOptions: mqtt.IClientOptions = { port, clean, clientId, @@ -243,7 +241,7 @@ export class Mqtt implements INodeType { const options = this.getNodeParameter('options', i); try { - if (sendInputData === true) { + if (sendInputData) { message = JSON.stringify(items[i].json); } else { message = this.getNodeParameter('message', i) as string; diff --git a/packages/nodes-base/nodes/MQTT/MqttTrigger.node.ts b/packages/nodes-base/nodes/MQTT/MqttTrigger.node.ts index 4554ae899e..4f7d746c95 100644 --- a/packages/nodes-base/nodes/MQTT/MqttTrigger.node.ts +++ b/packages/nodes-base/nodes/MQTT/MqttTrigger.node.ts @@ -10,8 +10,6 @@ import { import mqtt from 'mqtt'; -import { IClientOptions, ISubscriptionMap } from 'mqtt'; - export class MqttTrigger implements INodeType { description: INodeTypeDescription = { displayName: 'MQTT Trigger', @@ -99,8 +97,8 @@ export class MqttTrigger implements INodeType { let client: mqtt.MqttClient; - if (ssl === false) { - const clientOptions: IClientOptions = { + if (!ssl) { + const clientOptions: mqtt.IClientOptions = { port, clean, clientId, @@ -113,7 +111,7 @@ export class MqttTrigger implements INodeType { client = mqtt.connect(brokerUrl, clientOptions); } else { - const clientOptions: IClientOptions = { + const clientOptions: mqtt.IClientOptions = { port, clean, clientId, @@ -135,19 +133,19 @@ export class MqttTrigger implements INodeType { async function manualTriggerFunction() { await new Promise((resolve, reject) => { client.on('connect', () => { - client.subscribe(topicsQoS as ISubscriptionMap, (err, _granted) => { + client.subscribe(topicsQoS as mqtt.ISubscriptionMap, (err, _granted) => { if (err) { reject(err); } client.on('message', (topic: string, message: Buffer | string) => { let result: IDataObject = {}; - message = message.toString() as string; + message = message.toString(); if (options.jsonParseBody) { try { message = JSON.parse(message.toString()); - } catch (err) {} + } catch (error) {} } result.message = message; @@ -170,7 +168,7 @@ export class MqttTrigger implements INodeType { } if (this.getMode() === 'trigger') { - manualTriggerFunction(); + await manualTriggerFunction(); } async function closeFunction() { diff --git a/packages/nodes-base/nodes/Magento/GenericFunctions.ts b/packages/nodes-base/nodes/Magento/GenericFunctions.ts index 2a95aa8d27..41945a4377 100644 --- a/packages/nodes-base/nodes/Magento/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Magento/GenericFunctions.ts @@ -60,7 +60,7 @@ export async function magentoApiRequestAllItems( do { responseData = await magentoApiRequest.call(this, method, resource, body, query); returnData.push.apply(returnData, responseData[propertyName]); - query['current_page'] = query.current_page ? (query.current_page as number)++ : 1; + query.current_page = query.current_page ? (query.current_page as number)++ : 1; } while (returnData.length < responseData.total_count); return returnData; @@ -1012,8 +1012,8 @@ export async function getProductAttributes( const returnData: INodePropertyOptions[] = []; for (const attribute of attributes) { returnData.push({ - name: attribute.default_frontend_label as string, - value: attribute.attribute_code as string, + name: attribute.default_frontend_label, + value: attribute.attribute_code, }); } if (extraValue) { diff --git a/packages/nodes-base/nodes/Magento/Magento2.node.ts b/packages/nodes-base/nodes/Magento/Magento2.node.ts index bdcd565b43..d445235aaf 100644 --- a/packages/nodes-base/nodes/Magento/Magento2.node.ts +++ b/packages/nodes-base/nodes/Magento/Magento2.node.ts @@ -279,7 +279,7 @@ export class Magento2 implements INodeType { async getFilterableCustomerAttributes( this: ILoadOptionsFunctions, ): Promise { - return getProductAttributes.call(this, (attribute) => attribute.is_filterable === true); + return getProductAttributes.call(this, (attribute) => attribute.is_filterable); }, async getProductAttributes(this: ILoadOptionsFunctions): Promise { return getProductAttributes.call(this); @@ -295,7 +295,7 @@ export class Magento2 implements INodeType { async getSortableProductAttributes( this: ILoadOptionsFunctions, ): Promise { - return getProductAttributes.call(this, (attribute) => attribute.used_for_sort_by === true); + return getProductAttributes.call(this, (attribute) => attribute.used_for_sort_by); }, async getOrderAttributes(this: ILoadOptionsFunctions): Promise { return getOrderFields() @@ -402,7 +402,7 @@ export class Magento2 implements INodeType { if (operation === 'getAll') { //https://magento.redoc.ly/2.3.7-admin/tag/customerssearch const filterType = this.getNodeParameter('filterType', i) as string; - const sort = this.getNodeParameter('options.sort', i, {}) as { + const sortOption = this.getNodeParameter('options.sort', i, {}) as { sort: [{ direction: string; field: string }]; }; const returnAll = this.getNodeParameter('returnAll', 0); @@ -411,7 +411,7 @@ export class Magento2 implements INodeType { if (filterType === 'manual') { const filters = this.getNodeParameter('filters', i) as { conditions: Filter[] }; const matchType = this.getNodeParameter('matchType', i) as string; - qs = getFilterQuery(Object.assign(filters, { matchType }, sort)); + qs = getFilterQuery(Object.assign(filters, { matchType }, sortOption)); } else if (filterType === 'json') { const filterJson = this.getNodeParameter('filterJson', i) as string; if (validateJSON(filterJson) !== undefined) { @@ -426,14 +426,14 @@ export class Magento2 implements INodeType { search_criteria: {}, }; - if (Object.keys(sort).length !== 0) { + if (Object.keys(sortOption).length !== 0) { qs.search_criteria = { - sort_orders: sort.sort, + sort_orders: sortOption.sort, }; } } - if (returnAll === true) { + if (returnAll) { qs.search_criteria!.page_size = 100; responseData = await magentoApiRequestAllItems.call( this, @@ -581,7 +581,7 @@ export class Magento2 implements INodeType { if (operation === 'getAll') { //https://magento.redoc.ly/2.3.7-admin/tag/orders#operation/salesOrderRepositoryV1GetListGet const filterType = this.getNodeParameter('filterType', i) as string; - const sort = this.getNodeParameter('options.sort', i, {}) as { + const sortOption = this.getNodeParameter('options.sort', i, {}) as { sort: [{ direction: string; field: string }]; }; const returnAll = this.getNodeParameter('returnAll', 0); @@ -590,7 +590,7 @@ export class Magento2 implements INodeType { if (filterType === 'manual') { const filters = this.getNodeParameter('filters', i) as { conditions: Filter[] }; const matchType = this.getNodeParameter('matchType', i) as string; - qs = getFilterQuery(Object.assign(filters, { matchType }, sort)); + qs = getFilterQuery(Object.assign(filters, { matchType }, sortOption)); } else if (filterType === 'json') { const filterJson = this.getNodeParameter('filterJson', i) as string; if (validateJSON(filterJson) !== undefined) { @@ -604,14 +604,14 @@ export class Magento2 implements INodeType { qs = { search_criteria: {}, }; - if (Object.keys(sort).length !== 0) { + if (Object.keys(sortOption).length !== 0) { qs.search_criteria = { - sort_orders: sort.sort, + sort_orders: sortOption.sort, }; } } - if (returnAll === true) { + if (returnAll) { qs.search_criteria!.page_size = 100; responseData = await magentoApiRequestAllItems.call( this, @@ -703,7 +703,7 @@ export class Magento2 implements INodeType { if (operation === 'getAll') { //https://magento.redoc.ly/2.3.7-admin/tag/customerssearch const filterType = this.getNodeParameter('filterType', i) as string; - const sort = this.getNodeParameter('options.sort', i, {}) as { + const sortOption = this.getNodeParameter('options.sort', i, {}) as { sort: [{ direction: string; field: string }]; }; const returnAll = this.getNodeParameter('returnAll', 0); @@ -712,7 +712,7 @@ export class Magento2 implements INodeType { if (filterType === 'manual') { const filters = this.getNodeParameter('filters', i) as { conditions: Filter[] }; const matchType = this.getNodeParameter('matchType', i) as string; - qs = getFilterQuery(Object.assign(filters, { matchType }, sort)); + qs = getFilterQuery(Object.assign(filters, { matchType }, sortOption)); } else if (filterType === 'json') { const filterJson = this.getNodeParameter('filterJson', i) as string; if (validateJSON(filterJson) !== undefined) { @@ -726,14 +726,14 @@ export class Magento2 implements INodeType { qs = { search_criteria: {}, }; - if (Object.keys(sort).length !== 0) { + if (Object.keys(sortOption).length !== 0) { qs.search_criteria = { - sort_orders: sort.sort, + sort_orders: sortOption.sort, }; } } - if (returnAll === true) { + if (returnAll) { qs.search_criteria!.page_size = 100; responseData = await magentoApiRequestAllItems.call( this, diff --git a/packages/nodes-base/nodes/Magento/Types.d.ts b/packages/nodes-base/nodes/Magento/Types.d.ts index 2126a6c3f9..f05df332bb 100644 --- a/packages/nodes-base/nodes/Magento/Types.d.ts +++ b/packages/nodes-base/nodes/Magento/Types.d.ts @@ -1,3 +1,5 @@ +import { IDataObject } from 'n8n-workflow'; + export interface NewCustomer { customer?: Customer; password?: string; @@ -117,11 +119,9 @@ export interface CustomerAttributeMetadata { export interface CustomerAttributeMetadataOption { label?: string; value?: string; - options?: OptionOption[]; + options?: IDataObject[]; } -export interface OptionOption {} - export interface ValidationRule { name?: string; value?: string; diff --git a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts index 9bc04e9cf4..341d01d920 100644 --- a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts @@ -41,10 +41,9 @@ export async function mailCheckApiRequest( if (Object.keys(body).length === 0) { delete options.body; } - //@ts-ignore - return await this.helpers.request.call(this, options); + return await this.helpers.request!.call(this, options); } catch (error) { - if (error.response && error.response.body && error.response.body.message) { + if (error.response?.body?.message) { // Try to return the error prettier throw new Error( `Mailcheck error response [${error.statusCode}]: ${error.response.body.message}`, diff --git a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts index d54f8dfc62..c996d7714e 100644 --- a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts @@ -1690,7 +1690,7 @@ export class Mailchimp implements INodeType { const categoryId = this.getNodeParameter('groupCategory', i) as string; const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await mailchimpApiRequestAllItems.call( this, `/lists/${listId}/interest-categories/${categoryId}/interests`, @@ -1744,12 +1744,12 @@ export class Mailchimp implements INodeType { if (options.timestampOpt) { body.timestamp_opt = moment(options.timestampOpt as string).format( 'YYYY-MM-DD HH:MM:SS', - ) as string; + ); } if (options.timestampSignup) { body.timestamp_signup = moment(options.timestampSignup as string).format( 'YYYY-MM-DD HH:MM:SS', - ) as string; + ); } if (options.tags) { // @ts-ignore @@ -1762,9 +1762,9 @@ export class Mailchimp implements INodeType { const location: ILocation = {}; for (const key of Object.keys(locationValues)) { if (key === 'latitude') { - location.latitude = parseFloat(locationValues[key] as string) as number; + location.latitude = parseFloat(locationValues[key] as string); } else if (key === 'longitude') { - location.longitude = parseFloat(locationValues[key] as string) as number; + location.longitude = parseFloat(locationValues[key] as string); } } body.location = location; @@ -1773,9 +1773,9 @@ export class Mailchimp implements INodeType { .mergeFieldsValues as IDataObject[]; if (mergeFieldsValues) { const mergeFields = {}; - for (let i = 0; i < mergeFieldsValues.length; i++) { + for (let index = 0; index < mergeFieldsValues.length; index++) { // @ts-ignore - mergeFields[mergeFieldsValues[i].name] = mergeFieldsValues[i].value; + mergeFields[mergeFieldsValues[index].name] = mergeFieldsValues[index].value; } body.merge_fields = mergeFields; } @@ -1784,9 +1784,9 @@ export class Mailchimp implements INodeType { .groupsValues as IDataObject[]; if (groupsValues) { const groups = {}; - for (let i = 0; i < groupsValues.length; i++) { + for (let index = 0; index < groupsValues.length; index++) { // @ts-ignore - groups[groupsValues[i].categoryFieldId] = groupsValues[i].value; + groups[groupsValues[index].categoryFieldId] = groupsValues[index].value; } body.interests = groups; } @@ -1878,7 +1878,7 @@ export class Mailchimp implements INodeType { if (options.sinceLastChanged) { qs.since_last_changed = options.sinceLastChanged as string; } - if (returnAll === true) { + if (returnAll) { responseData = await mailchimpApiRequestAllItems.call( this, `/lists/${listId}/members`, @@ -1933,12 +1933,12 @@ export class Mailchimp implements INodeType { if (updateFields.timestampOpt) { body.timestamp_opt = moment(updateFields.timestampOpt as string).format( 'YYYY-MM-DD HH:MM:SS', - ) as string; + ); } if (updateFields.timestampSignup) { body.timestamp_signup = moment(updateFields.timestampSignup as string).format( 'YYYY-MM-DD HH:MM:SS', - ) as string; + ); } if (!jsonActive) { if (updateFields.locationFieldsUi) { @@ -1948,9 +1948,9 @@ export class Mailchimp implements INodeType { const location: ILocation = {}; for (const key of Object.keys(locationValues)) { if (key === 'latitude') { - location.latitude = parseFloat(locationValues[key] as string) as number; + location.latitude = parseFloat(locationValues[key] as string); } else if (key === 'longitude') { - location.longitude = parseFloat(locationValues[key] as string) as number; + location.longitude = parseFloat(locationValues[key] as string); } } body.location = location; @@ -1961,9 +1961,9 @@ export class Mailchimp implements INodeType { .mergeFieldsValues as IDataObject[]; if (mergeFieldsValues) { const mergeFields = {}; - for (let i = 0; i < mergeFieldsValues.length; i++) { + for (let index = 0; index < mergeFieldsValues.length; index++) { // @ts-ignore - mergeFields[mergeFieldsValues[i].name] = mergeFieldsValues[i].value; + mergeFields[mergeFieldsValues[index].name] = mergeFieldsValues[index].value; } body.merge_fields = mergeFields; } @@ -1973,9 +1973,9 @@ export class Mailchimp implements INodeType { .groupsValues as IDataObject[]; if (groupsValues) { const groups = {}; - for (let i = 0; i < groupsValues.length; i++) { + for (let index = 0; index < groupsValues.length; index++) { // @ts-ignore - groups[groupsValues[i].categoryFieldId] = groupsValues[i].value; + groups[groupsValues[index].categoryFieldId] = groupsValues[index].value; } body.interests = groups; } @@ -2116,7 +2116,7 @@ export class Mailchimp implements INodeType { if (options.sortField) { qs.sort_field = options.sortField as string; } - if (returnAll === true) { + if (returnAll) { responseData = await mailchimpApiRequestAllItems.call( this, `/campaigns`, diff --git a/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts b/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts index 8926a1c366..1fcd77b912 100644 --- a/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts @@ -1,7 +1,6 @@ import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { - IDataObject, ILoadOptionsFunctions, INodePropertyOptions, INodeType, @@ -264,7 +263,7 @@ export class MailchimpTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const webhookData = this.getWorkflowStaticData('node') as IDataObject; + const webhookData = this.getWorkflowStaticData('node'); const webhookName = this.getWebhookName(); if (webhookName === 'setup') { // Is a create webhook confirmation request diff --git a/packages/nodes-base/nodes/MailerLite/MailerLiteTrigger.node.ts b/packages/nodes-base/nodes/MailerLite/MailerLiteTrigger.node.ts index f9157531dc..987ab84c19 100644 --- a/packages/nodes-base/nodes/MailerLite/MailerLiteTrigger.node.ts +++ b/packages/nodes-base/nodes/MailerLite/MailerLiteTrigger.node.ts @@ -164,7 +164,7 @@ export class MailerLiteTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const body = this.getBodyData() as IDataObject; + const body = this.getBodyData(); const events = body.events as IDataObject[]; diff --git a/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts b/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts index 7653204da7..259b9cbc4b 100644 --- a/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts +++ b/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts @@ -110,7 +110,7 @@ export class Mailjet implements INodeType { const textBody = this.getNodeParameter('text', i) as string; const subject = this.getNodeParameter('subject', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); - const toEmail = (this.getNodeParameter('toEmail', i) as string).split(',') as string[]; + const toEmail = (this.getNodeParameter('toEmail', i) as string).split(','); const jsonParameters = this.getNodeParameter('jsonParameters', i); const body: IMessage = { @@ -157,7 +157,7 @@ export class Mailjet implements INodeType { body.TextPart = textBody; } if (additionalFields.bccEmail) { - const bccEmail = (additionalFields.bccEmail as string).split(',') as string[]; + const bccEmail = (additionalFields.bccEmail as string).split(','); for (const email of bccEmail) { body.Bcc!.push({ Email: email, @@ -165,7 +165,7 @@ export class Mailjet implements INodeType { } } if (additionalFields.ccAddresses) { - const ccEmail = (additionalFields.ccAddresses as string).split(',') as string[]; + const ccEmail = (additionalFields.ccAddresses as string).split(','); for (const email of ccEmail) { body.Cc!.push({ Email: email, @@ -177,7 +177,7 @@ export class Mailjet implements INodeType { } if (additionalFields.replyTo) { const replyTo = additionalFields.replyTo as string; - body['ReplyTo'] = { + body.ReplyTo = { Email: replyTo, }; } @@ -204,7 +204,7 @@ export class Mailjet implements INodeType { const templateId = parseInt(this.getNodeParameter('templateId', i) as string, 10); const subject = this.getNodeParameter('subject', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); - const toEmail = (this.getNodeParameter('toEmail', i) as string).split(',') as string[]; + const toEmail = (this.getNodeParameter('toEmail', i) as string).split(','); const jsonParameters = this.getNodeParameter('jsonParameters', i); const body: IMessage = { @@ -246,7 +246,7 @@ export class Mailjet implements INodeType { } if (additionalFields.bccEmail) { - const bccEmail = (additionalFields.bccEmail as string).split(',') as string[]; + const bccEmail = (additionalFields.bccEmail as string).split(','); for (const email of bccEmail) { body.Bcc!.push({ Email: email, @@ -254,7 +254,7 @@ export class Mailjet implements INodeType { } } if (additionalFields.ccEmail) { - const ccEmail = (additionalFields.ccEmail as string).split(',') as string[]; + const ccEmail = (additionalFields.ccEmail as string).split(','); for (const email of ccEmail) { body.Cc!.push({ Email: email, @@ -263,7 +263,7 @@ export class Mailjet implements INodeType { } if (additionalFields.replyTo) { const replyTo = additionalFields.replyTo as string; - body['ReplyTo'] = { + body.ReplyTo = { Email: replyTo, }; } diff --git a/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts b/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts index b66cf9ed18..da7af6817b 100644 --- a/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts @@ -42,7 +42,7 @@ export async function marketstackApiRequestAllItems( body: IDataObject = {}, qs: IDataObject = {}, ) { - const returnAll = this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll = this.getNodeParameter('returnAll', 0, false); const limit = this.getNodeParameter('limit', 0, 0); let responseData; diff --git a/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts b/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts index de5a1e00e4..f9954c930b 100644 --- a/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts +++ b/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts @@ -108,7 +108,7 @@ export class Marketstack implements INodeType { ) as EndOfDayDataFilters; validateTimeOptions.call(this, [ - latest !== undefined && latest !== false, + latest !== undefined && latest, specificDate !== undefined, dateFrom !== undefined && dateTo !== undefined, ]); diff --git a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts index c1c1eb9cfc..791527798b 100644 --- a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts @@ -13,9 +13,9 @@ export async function matrixApiRequest( resource: string, body: string | object = {}, query: object = {}, - headers: {} | undefined = undefined, - option: {} = {}, -): Promise { + headers: IDataObject | undefined = undefined, + option: IDataObject = {}, +) { let options: OptionsWithUri = { method, headers: headers || { @@ -34,8 +34,6 @@ export async function matrixApiRequest( delete options.qs; } try { - let response: any; - const credentials = await this.getCredentials('matrixApi'); options.uri = `${credentials.homeserverUrl}/_matrix/${ @@ -43,8 +41,7 @@ export async function matrixApiRequest( option.overridePrefix || 'client' }/r0${resource}`; options.headers!.Authorization = `Bearer ${credentials.accessToken}`; - //@ts-ignore - response = await this.helpers.request(options); + const response = await this.helpers.request!(options); // 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. @@ -64,7 +61,7 @@ export async function handleMatrixCall( ): Promise { if (resource === 'account') { if (operation === 'me') { - return await matrixApiRequest.call(this, 'GET', '/account/whoami'); + return matrixApiRequest.call(this, 'GET', '/account/whoami'); } } else if (resource === 'room') { if (operation === 'create') { @@ -78,20 +75,20 @@ export async function handleMatrixCall( if (roomAlias) { body.room_alias_name = roomAlias; } - return await matrixApiRequest.call(this, 'POST', `/createRoom`, body); + return matrixApiRequest.call(this, 'POST', `/createRoom`, body); } else if (operation === 'join') { const roomIdOrAlias = this.getNodeParameter('roomIdOrAlias', index) as string; - return await matrixApiRequest.call(this, 'POST', `/rooms/${roomIdOrAlias}/join`); + return matrixApiRequest.call(this, 'POST', `/rooms/${roomIdOrAlias}/join`); } else if (operation === 'leave') { const roomId = this.getNodeParameter('roomId', index) as string; - return await matrixApiRequest.call(this, 'POST', `/rooms/${roomId}/leave`); + return matrixApiRequest.call(this, 'POST', `/rooms/${roomId}/leave`); } else if (operation === 'invite') { const roomId = this.getNodeParameter('roomId', index) as string; const userId = this.getNodeParameter('userId', index) as string; const body: IDataObject = { user_id: userId, }; - return await matrixApiRequest.call(this, 'POST', `/rooms/${roomId}/invite`, body); + return matrixApiRequest.call(this, 'POST', `/rooms/${roomId}/invite`, body); } else if (operation === 'kick') { const roomId = this.getNodeParameter('roomId', index) as string; const userId = this.getNodeParameter('userId', index) as string; @@ -100,7 +97,7 @@ export async function handleMatrixCall( user_id: userId, reason, }; - return await matrixApiRequest.call(this, 'POST', `/rooms/${roomId}/kick`, body); + return matrixApiRequest.call(this, 'POST', `/rooms/${roomId}/kick`, body); } } else if (resource === 'message') { if (operation === 'create') { @@ -119,7 +116,7 @@ export async function handleMatrixCall( body.body = fallbackText; } const messageId = uuid(); - return await matrixApiRequest.call( + return matrixApiRequest.call( this, 'PUT', `/rooms/${roomId}/send/m.room.message/${messageId}`, @@ -127,7 +124,7 @@ export async function handleMatrixCall( ); } else if (operation === 'getAll') { const roomId = this.getNodeParameter('roomId', index) as string; - const returnAll = this.getNodeParameter('returnAll', index) as boolean; + const returnAll = this.getNodeParameter('returnAll', index); const otherOptions = this.getNodeParameter('otherOptions', index) as IDataObject; const returnData: IDataObject[] = []; @@ -181,7 +178,7 @@ export async function handleMatrixCall( if (operation === 'get') { const roomId = this.getNodeParameter('roomId', index) as string; const eventId = this.getNodeParameter('eventId', index) as string; - return await matrixApiRequest.call(this, 'GET', `/rooms/${roomId}/event/${eventId}`); + return matrixApiRequest.call(this, 'GET', `/rooms/${roomId}/event/${eventId}`); } } else if (resource === 'media') { if (operation === 'upload') { @@ -192,7 +189,6 @@ export async function handleMatrixCall( let body; const qs: IDataObject = {}; const headers: IDataObject = {}; - let filename; if ( item.binary === undefined || @@ -208,12 +204,12 @@ export async function handleMatrixCall( // @ts-ignore qs.filename = item.binary[binaryPropertyName].fileName; //@ts-ignore - filename = item.binary[binaryPropertyName].fileName; + const filename = item.binary[binaryPropertyName].fileName; body = await this.helpers.getBinaryDataBuffer(index, binaryPropertyName); //@ts-ignore headers['Content-Type'] = item.binary[binaryPropertyName].mimeType; - headers['accept'] = 'application/json,text/*;q=0.99'; + headers.accept = 'application/json,text/*;q=0.99'; const uploadRequestResult = await matrixApiRequest.call( this, @@ -234,7 +230,7 @@ export async function handleMatrixCall( url: uploadRequestResult.content_uri, }; const messageId = uuid(); - return await matrixApiRequest.call( + return matrixApiRequest.call( this, 'PUT', `/rooms/${roomId}/send/m.room.message/${messageId}`, diff --git a/packages/nodes-base/nodes/Mattermost/v1/MattermostV1.node.ts b/packages/nodes-base/nodes/Mattermost/v1/MattermostV1.node.ts index e771f1718d..54999e3c81 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/MattermostV1.node.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/MattermostV1.node.ts @@ -19,6 +19,6 @@ export class MattermostV1 implements INodeType { methods = { loadOptions }; async execute(this: IExecuteFunctions) { - return await router.call(this); + return router.call(this); } } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/members/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/members/execute.ts index cd72b2089e..1a9290821e 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/members/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/members/execute.ts @@ -9,8 +9,8 @@ export async function members( index: number, ): Promise { const channelId = this.getNodeParameter('channelId', index) as string; - const returnAll = this.getNodeParameter('returnAll', index) as boolean; - const resolveData = this.getNodeParameter('resolveData', index) as boolean; + const returnAll = this.getNodeParameter('returnAll', index); + const resolveData = this.getNodeParameter('resolveData', index); const limit = this.getNodeParameter('limit', index, 0); const body = {} as IDataObject; @@ -18,7 +18,7 @@ export async function members( const requestMethod = 'GET'; const endpoint = `channels/${channelId}/members`; - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', index); } 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 9f2ff5c19d..35ab386916 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 @@ -10,7 +10,7 @@ export async function getAll( this: IExecuteFunctions, index: number, ): Promise { - const returnAll = this.getNodeParameter('returnAll', index) as boolean; + const returnAll = this.getNodeParameter('returnAll', index); const additionalFields = this.getNodeParameter('additionalFields', index); const qs = {} as IDataObject; @@ -97,7 +97,7 @@ export async function getAll( qs.sort = ''; } - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', index); } 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 791007d97b..6ce4fa08d8 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 @@ -11,7 +11,7 @@ export async function getById( const qs = {} as IDataObject; const requestMethod = 'POST'; const endpoint = 'users/ids'; - const userIds = (this.getNodeParameter('userIds', index) as string).split(',') as string[]; + const userIds = (this.getNodeParameter('userIds', index) as string).split(','); const additionalFields = this.getNodeParameter('additionalFields', index); const body = userIds; diff --git a/packages/nodes-base/nodes/Mautic/Mautic.node.ts b/packages/nodes-base/nodes/Mautic/Mautic.node.ts index 9e875416d7..2ca3d48e20 100644 --- a/packages/nodes-base/nodes/Mautic/Mautic.node.ts +++ b/packages/nodes-base/nodes/Mautic/Mautic.node.ts @@ -424,7 +424,7 @@ export class Mautic implements INodeType { Object.assign(body, rest); responseData = await mauticApiRequest.call(this, 'POST', '/companies/new', body); responseData = responseData.company; - if (simple === true) { + if (simple) { responseData = responseData.fields.all; } } @@ -536,7 +536,7 @@ export class Mautic implements INodeType { body, ); responseData = responseData.company; - if (simple === true) { + if (simple) { responseData = responseData.fields.all; } } @@ -546,7 +546,7 @@ export class Mautic implements INodeType { const simple = this.getNodeParameter('simple', i) as boolean; responseData = await mauticApiRequest.call(this, 'GET', `/companies/${companyId}`); responseData = responseData.company; - if (simple === true) { + if (simple) { responseData = responseData.fields.all; } } @@ -556,7 +556,7 @@ export class Mautic implements INodeType { const simple = this.getNodeParameter('simple', i) as boolean; const additionalFields = this.getNodeParameter('additionalFields', i); qs = Object.assign(qs, additionalFields); - if (returnAll === true) { + if (returnAll) { responseData = await mauticApiRequestAllItems.call( this, 'companies', @@ -575,7 +575,7 @@ export class Mautic implements INodeType { responseData = responseData.companies; responseData = Object.values(responseData); } - if (simple === true) { + if (simple) { //@ts-ignore responseData = responseData.map((item) => item.fields.all); } @@ -590,7 +590,7 @@ export class Mautic implements INodeType { `/companies/${companyId}/delete`, ); responseData = responseData.company; - if (simple === true) { + if (simple) { responseData = responseData.fields.all; } } @@ -843,7 +843,7 @@ export class Mautic implements INodeType { qs.orderBy = snakeCase(qs.orderBy as string); } - if (returnAll === true) { + if (returnAll) { responseData = await mauticApiRequestAllItems.call( this, 'contacts', diff --git a/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts b/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts index 697164b6e4..a80a47f266 100644 --- a/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts +++ b/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts @@ -102,6 +102,7 @@ export class MauticTrigger implements INodeType { }, ], }; + methods = { loadOptions: { // Get all the events to display them to user so that he can @@ -123,6 +124,7 @@ export class MauticTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/Medium/GenericFunctions.ts b/packages/nodes-base/nodes/Medium/GenericFunctions.ts index 9d47838f8c..5ca64a9611 100644 --- a/packages/nodes-base/nodes/Medium/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Medium/GenericFunctions.ts @@ -37,7 +37,7 @@ export async function mediumApiRequest( if (authenticationMethod === 'accessToken') { const credentials = await this.getCredentials('mediumApi'); - options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; + options.headers!.Authorization = `Bearer ${credentials.accessToken}`; return await this.helpers.request!(options); } else { diff --git a/packages/nodes-base/nodes/Medium/Medium.node.ts b/packages/nodes-base/nodes/Medium/Medium.node.ts index b9422dd1cf..caff2ab81f 100644 --- a/packages/nodes-base/nodes/Medium/Medium.node.ts +++ b/packages/nodes-base/nodes/Medium/Medium.node.ts @@ -354,6 +354,7 @@ export class Medium implements INodeType { }, ], }; + methods = { loadOptions: { // Get all the available publications to display them to user so that he can @@ -400,8 +401,8 @@ export class Medium implements INodeType { for (let i = 0; i < items.length; i++) { qs = {}; try { - resource = this.getNodeParameter('resource', i) as string; - operation = this.getNodeParameter('operation', i) as string; + resource = this.getNodeParameter('resource', i); + operation = this.getNodeParameter('operation', i); if (resource === 'post') { //https://github.com/Medium/medium-api-docs diff --git a/packages/nodes-base/nodes/Merge/v2/GenericFunctions.ts b/packages/nodes-base/nodes/Merge/v2/GenericFunctions.ts index 8c91967158..44a9598549 100644 --- a/packages/nodes-base/nodes/Merge/v2/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Merge/v2/GenericFunctions.ts @@ -129,7 +129,7 @@ export function findMatches( [data1, data2] = [data2, data1]; } - const disableDotNotation = (options.disableDotNotation as boolean) || false; + const disableDotNotation = options.disableDotNotation || false; const multipleMatches = (options.multipleMatches as string) || 'all'; const filteredData = { @@ -147,11 +147,11 @@ export function findMatches( fieldsToMatch.forEach((matchCase) => { let valueToCompare; if (disableDotNotation) { - valueToCompare = entry1.json[matchCase.field1 as string]; + valueToCompare = entry1.json[matchCase.field1]; } else { - valueToCompare = get(entry1.json, matchCase.field1 as string); + valueToCompare = get(entry1.json, matchCase.field1); } - lookup[matchCase.field2 as string] = valueToCompare; + lookup[matchCase.field2] = valueToCompare; }); for (const fieldValue of Object.values(lookup)) { @@ -230,10 +230,10 @@ export function mergeMatched( [entry] = addSuffixToEntriesKeys([entry], suffix1); matches = addSuffixToEntriesKeys(matches, suffix2); - json = mergeIntoSingleObject({ ...entry.json }, ...matches.map((match) => match.json)); + json = mergeIntoSingleObject({ ...entry.json }, ...matches.map((item) => item.json)); binary = mergeIntoSingleObject( { ...entry.binary }, - ...matches.map((match) => match.binary as IDataObject), + ...matches.map((item) => item.binary as IDataObject), ); } else { let preferInput1 = 'preferInput1'; @@ -251,21 +251,21 @@ export function mergeMatched( const [firstMatch, ...restMatches] = matches; json = mergeIntoSingleObject( { ...firstMatch.json }, - ...restMatches.map((match) => match.json), + ...restMatches.map((item) => item.json), entry.json, ); binary = mergeIntoSingleObject( { ...firstMatch.binary }, - ...restMatches.map((match) => match.binary as IDataObject), + ...restMatches.map((item) => item.binary as IDataObject), entry.binary as IDataObject, ); } if (resolveClash === preferInput2) { - json = mergeIntoSingleObject({ ...entry.json }, ...matches.map((match) => match.json)); + json = mergeIntoSingleObject({ ...entry.json }, ...matches.map((item) => item.json)); binary = mergeIntoSingleObject( { ...entry.binary }, - ...matches.map((match) => match.binary as IDataObject), + ...matches.map((item) => item.binary as IDataObject), ); } } diff --git a/packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts b/packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts index 942909e173..ef41955aa4 100644 --- a/packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts +++ b/packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts @@ -448,16 +448,16 @@ export class MergeV2 implements INodeType { const input1 = checkInput( this.getInputData(0), - matchFields.map((pair) => pair.field1 as string), - (options.disableDotNotation as boolean) || false, + matchFields.map((pair) => pair.field1), + options.disableDotNotation || false, 'Input 1', ); if (!input1) return [returnData]; const input2 = checkInput( this.getInputData(1), - matchFields.map((pair) => pair.field2 as string), - (options.disableDotNotation as boolean) || false, + matchFields.map((pair) => pair.field2), + options.disableDotNotation || false, 'Input 2', ); diff --git a/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts b/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts index 31770a46ba..2344ac7e93 100644 --- a/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts +++ b/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts @@ -297,8 +297,8 @@ export class MessageBird implements INodeType { for (let i = 0; i < items.length; i++) { qs = {}; try { - resource = this.getNodeParameter('resource', i) as string; - operation = this.getNodeParameter('operation', i) as string; + resource = this.getNodeParameter('resource', i); + operation = this.getNodeParameter('operation', i); if (resource === 'sms') { //https://developers.messagebird.com/api/sms-messaging/#sms-api diff --git a/packages/nodes-base/nodes/Metabase/QuestionsDescription.ts b/packages/nodes-base/nodes/Metabase/QuestionsDescription.ts index 14a9c491de..4bbd62de84 100644 --- a/packages/nodes-base/nodes/Metabase/QuestionsDescription.ts +++ b/packages/nodes-base/nodes/Metabase/QuestionsDescription.ts @@ -79,7 +79,7 @@ export const questionsOperations: INodeProperties[] = [ console.log(items[i].json); delete items[i].binary; } else { - items[i].binary!['data'] = await this.helpers.prepareBinaryData( + items[i].binary!.data = await this.helpers.prepareBinaryData( response.body as Buffer, 'data', response.headers['content-type'], diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts index c60d55152e..badd717691 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts @@ -58,7 +58,7 @@ export async function microsoftApiRequestAllItems( let responseData; let uri: string | undefined; - query['$top'] = 100; + query.$top = 100; do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts index f1e8ccb020..c6e40da26e 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts @@ -63,49 +63,49 @@ export class MicrosoftDynamicsCrm implements INodeType { methods = { loadOptions: { async getAccountCategories(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'accountcategorycode'); + return getPicklistOptions.call(this, 'account', 'accountcategorycode'); }, async getAccountRatingCodes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'accountratingcode'); + return getPicklistOptions.call(this, 'account', 'accountratingcode'); }, async getAddressTypes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'address1_addresstypecode'); + return getPicklistOptions.call(this, 'account', 'address1_addresstypecode'); }, async getBusinessTypes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'businesstypecode'); + return getPicklistOptions.call(this, 'account', 'businesstypecode'); }, async getCustomerSizeCodes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'customersizecode'); + return getPicklistOptions.call(this, 'account', 'customersizecode'); }, async getCustomerTypeCodes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'customertypecode'); + return getPicklistOptions.call(this, 'account', 'customertypecode'); }, async getIndustryCodes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'industrycode'); + return getPicklistOptions.call(this, 'account', 'industrycode'); }, async getPaymentTermsCodes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'paymenttermscode'); + return getPicklistOptions.call(this, 'account', 'paymenttermscode'); }, async getPreferredAppointmentDayCodes( this: ILoadOptionsFunctions, ): Promise { - return await getPicklistOptions.call(this, 'account', 'preferredappointmentdaycode'); + return getPicklistOptions.call(this, 'account', 'preferredappointmentdaycode'); }, async getPreferredAppointmentTimeCodes( this: ILoadOptionsFunctions, ): Promise { - return await getPicklistOptions.call(this, 'account', 'preferredappointmenttimecode'); + return getPicklistOptions.call(this, 'account', 'preferredappointmenttimecode'); }, async getPreferredContactMethodCodes( this: ILoadOptionsFunctions, ): Promise { - return await getPicklistOptions.call(this, 'account', 'preferredcontactmethodcode'); + return getPicklistOptions.call(this, 'account', 'preferredcontactmethodcode'); }, async getShippingMethodCodes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'shippingmethodcode'); + return getPicklistOptions.call(this, 'account', 'shippingmethodcode'); }, async getTerritoryCodes(this: ILoadOptionsFunctions): Promise { - return await getPicklistOptions.call(this, 'account', 'territorycode'); + return getPicklistOptions.call(this, 'account', 'territorycode'); }, async getAccountFields(this: ILoadOptionsFunctions): Promise { const fields = await getEntityFields.call(this, 'account'); @@ -177,9 +177,9 @@ export class MicrosoftDynamicsCrm implements INodeType { if (options.returnFields) { options.returnFields.push('accountid'); - qs['$select'] = options.returnFields.join(','); + qs.$select = options.returnFields.join(','); } else { - qs['$select'] = 'accountid'; + qs.$select = 'accountid'; } responseData = await microsoftApiRequest.call(this, 'POST', `/accounts`, body, qs); @@ -197,10 +197,10 @@ export class MicrosoftDynamicsCrm implements INodeType { const accountId = this.getNodeParameter('accountId', i) as string; const options = this.getNodeParameter('options', i); if (options.returnFields) { - qs['$select'] = (options.returnFields as string[]).join(','); + qs.$select = (options.returnFields as string[]).join(','); } if (options.expandFields) { - qs['$expand'] = (options.expandFields as string[]).join(','); + qs.$expand = (options.expandFields as string[]).join(','); } responseData = await microsoftApiRequest.call( this, @@ -217,13 +217,13 @@ export class MicrosoftDynamicsCrm implements INodeType { const options = this.getNodeParameter('options', i); const filters = this.getNodeParameter('filters', i); if (options.returnFields) { - qs['$select'] = (options.returnFields as string[]).join(','); + qs.$select = (options.returnFields as string[]).join(','); } if (options.expandFields) { - qs['$expand'] = (options.expandFields as string[]).join(','); + qs.$expand = (options.expandFields as string[]).join(','); } if (filters.query) { - qs['$filter'] = filters.query as string; + qs.$filter = filters.query as string; } if (returnAll) { responseData = await microsoftApiRequestAllItems.call( @@ -235,7 +235,7 @@ export class MicrosoftDynamicsCrm implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', 0); + qs.$top = this.getNodeParameter('limit', 0); responseData = await microsoftApiRequest.call(this, 'GET', `/accounts`, {}, qs); responseData = responseData.value; } @@ -260,9 +260,9 @@ export class MicrosoftDynamicsCrm implements INodeType { if (options.returnFields) { options.returnFields.push('accountid'); - qs['$select'] = options.returnFields.join(','); + qs.$select = options.returnFields.join(','); } else { - qs['$select'] = 'accountid'; + qs.$select = 'accountid'; } responseData = await microsoftApiRequest.call( diff --git a/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts index 849048ddc8..aacb40c23d 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts @@ -46,13 +46,13 @@ export async function microsoftApiRequestAllItems( let responseData; let uri: string | undefined; - query['$top'] = 100; + query.$top = 100; do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData['@odata.nextLink']; - if (uri && uri.includes('$top')) { - delete query['$top']; + if (uri?.includes('$top')) { + delete query.$top; } returnData.push.apply(returnData, responseData[propertyName]); } while (responseData['@odata.nextLink'] !== undefined); @@ -72,14 +72,14 @@ export async function microsoftApiRequestAllItemsSkip( const returnData: IDataObject[] = []; let responseData; - query['$top'] = 100; - query['$skip'] = 0; + query.$top = 100; + query.$skip = 0; do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); - query['$skip'] += query['$top']; + query.$skip += query.$top; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['value'].length !== 0); + } 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 e8d919c709..008aa2c0bb 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts @@ -265,10 +265,10 @@ export class MicrosoftExcel implements INodeType { if (rawData) { const filters = this.getNodeParameter('filters', i); if (filters.fields) { - qs['$select'] = filters.fields; + qs.$select = filters.fields; } } - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItemsSkip.call( this, 'value', @@ -278,7 +278,7 @@ export class MicrosoftExcel implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call( this, 'GET', @@ -327,10 +327,10 @@ export class MicrosoftExcel implements INodeType { if (rawData) { const filters = this.getNodeParameter('filters', i); if (filters.fields) { - qs['$select'] = filters.fields; + qs.$select = filters.fields; } } - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItemsSkip.call( this, 'value', @@ -341,7 +341,7 @@ export class MicrosoftExcel implements INodeType { ); } else { const rowsQs = { ...qs }; - rowsQs['$top'] = this.getNodeParameter('limit', i); + rowsQs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call( this, 'GET', @@ -353,7 +353,7 @@ export class MicrosoftExcel implements INodeType { } if (!rawData) { const columnsQs = { ...qs }; - columnsQs['$select'] = 'name'; + columnsQs.$select = 'name'; // TODO: That should probably be cached in the future let columns = await microsoftApiRequestAllItemsSkip.call( this, @@ -365,14 +365,14 @@ export class MicrosoftExcel implements INodeType { ); //@ts-ignore columns = columns.map((column) => column.name); - for (let i = 0; i < responseData.length; i++) { + for (let index = 0; index < responseData.length; index++) { const object: IDataObject = {}; for (let y = 0; y < columns.length; y++) { - object[columns[y]] = responseData[i].values[0][y]; + object[columns[y]] = responseData[index].values[0][y]; } const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray({ ...object }), - { itemData: { item: i } }, + { itemData: { item: index } }, ); returnData.push(...executionData); @@ -419,7 +419,7 @@ export class MicrosoftExcel implements INodeType { {}, ); - qs['$select'] = 'name'; + qs.$select = 'name'; // TODO: That should probably be cached in the future let columns = await microsoftApiRequestAllItemsSkip.call( this, @@ -438,10 +438,10 @@ export class MicrosoftExcel implements INodeType { } result.length = 0; - for (let i = 0; i < responseData.length; i++) { + for (let index = 0; index < responseData.length; index++) { const object: IDataObject = {}; for (let y = 0; y < columns.length; y++) { - object[columns[y]] = responseData[i].values[0][y]; + object[columns[y]] = responseData[index].values[0][y]; } result.push({ ...object }); } @@ -522,9 +522,9 @@ export class MicrosoftExcel implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); const filters = this.getNodeParameter('filters', i); if (filters.fields) { - qs['$select'] = filters.fields; + qs.$select = filters.fields; } - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItems.call( this, 'value', @@ -534,7 +534,7 @@ export class MicrosoftExcel implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call( this, 'GET', @@ -584,9 +584,9 @@ export class MicrosoftExcel implements INodeType { const workbookId = this.getNodeParameter('workbook', i) as string; const filters = this.getNodeParameter('filters', i); if (filters.fields) { - qs['$select'] = filters.fields; + qs.$select = filters.fields; } - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItems.call( this, 'value', @@ -596,7 +596,7 @@ export class MicrosoftExcel implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call( this, 'GET', @@ -616,7 +616,7 @@ export class MicrosoftExcel implements INodeType { if (rawData) { const filters = this.getNodeParameter('filters', i); if (filters.fields) { - qs['$select'] = filters.fields; + qs.$select = filters.fields; } } @@ -637,14 +637,14 @@ export class MicrosoftExcel implements INodeType { }); } const keyValues = responseData.values[keyRow]; - for (let i = dataStartRow; i < responseData.values.length; i++) { + for (let index = dataStartRow; index < responseData.values.length; index++) { const object: IDataObject = {}; for (let y = 0; y < keyValues.length; y++) { - object[keyValues[y]] = responseData.values[i][y]; + object[keyValues[y]] = responseData.values[index][y]; } const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray({ ...object }), - { itemData: { item: i } }, + { itemData: { item: index } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts index 3aabf8ca26..d4d6509469 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts @@ -55,13 +55,13 @@ export async function microsoftApiRequestAllItems( let responseData; let uri: string | undefined; - query['$top'] = 100; + query.$top = 100; do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData['@odata.nextLink']; - if (uri && uri.includes('$top')) { - delete query['$top']; + if (uri?.includes('$top')) { + delete query.$top; } returnData.push.apply(returnData, responseData[propertyName]); } while (responseData['@odata.nextLink'] !== undefined); @@ -81,14 +81,14 @@ export async function microsoftApiRequestAllItemsSkip( const returnData: IDataObject[] = []; let responseData; - query['$top'] = 100; - query['$skip'] = 0; + query.$top = 100; + query.$skip = 0; do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); - query['$skip'] += query['$top']; + query.$skip += query.$top; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['value'].length !== 0); + } while (responseData.value.length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts index 0d237d07e3..71285ed852 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts @@ -7,13 +7,7 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IBinaryKeyData, - IDataObject, - INodeExecutionData, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function microsoftApiRequest( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, @@ -75,7 +69,7 @@ export async function microsoftApiRequestAllItems( let responseData; let uri: string | undefined; - query['$top'] = 100; + query.$top = 100; do { responseData = await microsoftApiRequest.call( @@ -107,8 +101,8 @@ export async function microsoftApiRequestAllItemsSkip( const returnData: IDataObject[] = []; let responseData; - query['$top'] = 100; - query['$skip'] = 0; + query.$top = 100; + query.$skip = 0; do { responseData = await microsoftApiRequest.call( @@ -120,9 +114,9 @@ export async function microsoftApiRequestAllItemsSkip( undefined, headers, ); - query['$skip'] += query['$top']; + query.$skip += query.$top; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['value'].length !== 0); + } while (responseData.value.length !== 0); return returnData; } @@ -145,9 +139,9 @@ export function createMessage(fields: IDataObject) { contentType: fields.bodyContentType, }; - message['body'] = bodyObject; - delete fields['bodyContent']; - delete fields['bodyContentType']; + message.body = bodyObject; + delete fields.bodyContent; + delete fields.bodyContentType; } // Handle custom headers @@ -255,7 +249,7 @@ export async function binaryToAttachments( ); } - const binaryData = (binary as IBinaryKeyData)[binaryPropertyName]; + const binaryData = binary[binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); return { '@odata.type': '#microsoft.graph.fileAttachment', diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts b/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts index da9fb9c269..04cf8e2606 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts @@ -165,11 +165,11 @@ export class MicrosoftOutlook implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); if (additionalFields.fields) { - qs['$select'] = additionalFields.fields; + qs.$select = additionalFields.fields; } if (additionalFields.filter) { - qs['$filter'] = additionalFields.filter; + qs.$filter = additionalFields.filter; } responseData = await microsoftApiRequest.call( @@ -252,7 +252,7 @@ export class MicrosoftOutlook implements INodeType { .attachments as IDataObject[]; // Handle attachments - body['attachments'] = await binaryToAttachments.call(this, attachments, items, i); + body.attachments = await binaryToAttachments.call(this, attachments, items, i); } responseData = await microsoftApiRequest.call(this, 'POST', `/messages`, body, {}); @@ -272,16 +272,12 @@ export class MicrosoftOutlook implements INodeType { for (let i = 0; i < length; i++) { try { const messageId = this.getNodeParameter('messageId', i); - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - {}, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); - if (additionalFields && additionalFields.recipients) { - const recipients = ( - (additionalFields.recipients as string).split(',') as string[] - ).filter((email) => !!email); + if (additionalFields?.recipients) { + const recipients = (additionalFields.recipients as string) + .split(',') + .filter((email) => !!email); if (recipients.length !== 0) { await microsoftApiRequest.call(this, 'PATCH', `/messages/${messageId}`, { toRecipients: recipients.map((recipient: string) => makeRecipient(recipient)), @@ -315,11 +311,7 @@ export class MicrosoftOutlook implements INodeType { const replyType = this.getNodeParameter('replyType', i) as string; const comment = this.getNodeParameter('comment', i) as string; const send = this.getNodeParameter('send', i, false) as boolean; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - {}, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); const body: IDataObject = {}; @@ -359,7 +351,7 @@ export class MicrosoftOutlook implements INodeType { } } - if (send === true) { + if (send) { await microsoftApiRequest.call(this, 'POST', `/messages/${responseData.id}/send`); } @@ -437,16 +429,16 @@ export class MicrosoftOutlook implements INodeType { additionalFields = this.getNodeParameter('additionalFields', i); if (additionalFields.fields) { - qs['$select'] = additionalFields.fields; + qs.$select = additionalFields.fields; } if (additionalFields.filter) { - qs['$filter'] = additionalFields.filter; + qs.$filter = additionalFields.filter; } const endpoint = '/messages'; - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItems.call( this, 'value', @@ -456,7 +448,7 @@ export class MicrosoftOutlook implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs); responseData = responseData.value; } @@ -539,7 +531,7 @@ export class MicrosoftOutlook implements INodeType { .attachments as IDataObject[]; // Handle attachments - message['attachments'] = await binaryToAttachments.call(this, attachments, items, i); + message.attachments = await binaryToAttachments.call(this, attachments, items, i); } const body: IDataObject = { @@ -743,9 +735,9 @@ export class MicrosoftOutlook implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); // Have sane defaults so we don't fetch attachment data in this operation - qs['$select'] = 'id,lastModifiedDateTime,name,contentType,size,isInline'; + qs.$select = 'id,lastModifiedDateTime,name,contentType,size,isInline'; if (additionalFields.fields) { - qs['$select'] = additionalFields.fields; + qs.$select = additionalFields.fields; } responseData = await microsoftApiRequest.call( @@ -774,17 +766,17 @@ export class MicrosoftOutlook implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); // Have sane defaults so we don't fetch attachment data in this operation - qs['$select'] = 'id,lastModifiedDateTime,name,contentType,size,isInline'; + qs.$select = 'id,lastModifiedDateTime,name,contentType,size,isInline'; if (additionalFields.fields) { - qs['$select'] = additionalFields.fields; + qs.$select = additionalFields.fields; } if (additionalFields.filter) { - qs['$filter'] = additionalFields.filter; + qs.$filter = additionalFields.filter; } const endpoint = `/messages/${messageId}/attachments`; - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItems.call( this, 'value', @@ -794,7 +786,7 @@ export class MicrosoftOutlook implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs); responseData = responseData.value; } @@ -874,11 +866,11 @@ export class MicrosoftOutlook implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); if (additionalFields.fields) { - qs['$select'] = additionalFields.fields; + qs.$select = additionalFields.fields; } if (additionalFields.filter) { - qs['$filter'] = additionalFields.filter; + qs.$filter = additionalFields.filter; } responseData = await microsoftApiRequest.call( this, @@ -905,14 +897,14 @@ export class MicrosoftOutlook implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); if (additionalFields.fields) { - qs['$select'] = additionalFields.fields; + qs.$select = additionalFields.fields; } if (additionalFields.filter) { - qs['$filter'] = additionalFields.filter; + qs.$filter = additionalFields.filter; } - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItems.call( this, 'value', @@ -922,7 +914,7 @@ export class MicrosoftOutlook implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call(this, 'GET', '/mailFolders', {}, qs); responseData = responseData.value; } @@ -945,11 +937,11 @@ export class MicrosoftOutlook implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); if (additionalFields.fields) { - qs['$select'] = additionalFields.fields; + qs.$select = additionalFields.fields; } if (additionalFields.filter) { - qs['$filter'] = additionalFields.filter; + qs.$filter = additionalFields.filter; } if (returnAll) { @@ -961,7 +953,7 @@ export class MicrosoftOutlook implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call( this, 'GET', @@ -1019,11 +1011,11 @@ export class MicrosoftOutlook implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); if (additionalFields.fields) { - qs['$select'] = additionalFields.fields; + qs.$select = additionalFields.fields; } if (additionalFields.filter) { - qs['$filter'] = additionalFields.filter; + qs.$filter = additionalFields.filter; } const endpoint = `/mailFolders/${folderId}/messages`; @@ -1036,7 +1028,7 @@ export class MicrosoftOutlook implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs); responseData = responseData.value; } diff --git a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts index b73dc43cea..df7c2c7d69 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/ban-types */ import { deepCopy, IDataObject, INodeExecutionData } from 'n8n-workflow'; import { ITables } from './TableInterface'; @@ -60,10 +61,13 @@ export function createTableStruct( * @param {function} buildQueryQueue function that builds the queue of promises */ -export function executeQueryQueue(tables: ITables, buildQueryQueue: Function): Promise { +export async function executeQueryQueue( + tables: ITables, + buildQueryQueue: Function, +): Promise { return Promise.all( - Object.keys(tables).map((table) => { - const columnsResults = Object.keys(tables[table]).map((columnString) => { + Object.keys(tables).map(async (table) => { + const columnsResults = Object.keys(tables[table]).map(async (columnString) => { return Promise.all( buildQueryQueue({ table, diff --git a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts index c01ad72db9..4b5bdca49a 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts @@ -311,13 +311,14 @@ export class MicrosoftSql implements INodeType { ({ table, columnString, + // eslint-disable-next-line @typescript-eslint/no-shadow items, }: { table: string; columnString: string; items: IDataObject[]; }): Array> => { - return chunk(items, 1000).map((insertValues) => { + return chunk(items, 1000).map(async (insertValues) => { const values = insertValues.map((item: IDataObject) => extractValues(item)).join(','); return pool .request() @@ -346,13 +347,14 @@ export class MicrosoftSql implements INodeType { ({ table, columnString, + // eslint-disable-next-line @typescript-eslint/no-shadow items, }: { table: string; columnString: string; items: IDataObject[]; }): Array> => { - return items.map((item) => { + return items.map(async (item) => { const columns = columnString.split(',').map((column) => column.trim()); const setValues = extractUpdateSet(item, columns); @@ -369,29 +371,29 @@ export class MicrosoftSql implements INodeType { // delete // ---------------------------------- - const tables = items.reduce((tables, item, index) => { + const tables = items.reduce((acc, item, index) => { const table = this.getNodeParameter('table', index) as string; const deleteKey = this.getNodeParameter('deleteKey', index) as string; - if (tables[table] === undefined) { - tables[table] = {}; + if (acc[table] === undefined) { + acc[table] = {}; } - if (tables[table][deleteKey] === undefined) { - tables[table][deleteKey] = []; + if (acc[table][deleteKey] === undefined) { + acc[table][deleteKey] = []; } - tables[table][deleteKey].push(item); - return tables; + acc[table][deleteKey].push(item); + return acc; }, {} as ITables); const queriesResults = await Promise.all( - Object.keys(tables).map((table) => { - const deleteKeyResults = Object.keys(tables[table]).map((deleteKey) => { + Object.keys(tables).map(async (table) => { + const deleteKeyResults = Object.keys(tables[table]).map(async (deleteKey) => { const deleteItemsList = chunk( tables[table][deleteKey].map((item) => copyInputItem(item as INodeExecutionData, [deleteKey]), ), 1000, ); - const queryQueue = deleteItemsList.map((deleteValues) => { + const queryQueue = deleteItemsList.map(async (deleteValues) => { return pool .request() .query( @@ -422,7 +424,7 @@ export class MicrosoftSql implements INodeType { ); } } catch (error) { - if (this.continueOnFail() === true) { + if (this.continueOnFail()) { responseData = items; } else { await pool.close(); diff --git a/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts index 6933d76ea3..7c53d59bcb 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts @@ -73,14 +73,14 @@ export async function microsoftApiRequestAllItemsSkip( const returnData: IDataObject[] = []; let responseData; - query['$top'] = 100; - query['$skip'] = 0; + query.$top = 100; + query.$skip = 0; do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); - query['$skip'] += query['$top']; + query.$skip += query.$top; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['value'].length !== 0); + } while (responseData.value.length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts index 9101bb5505..2cb96f44b3 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts @@ -32,7 +32,7 @@ export async function microsoftApiRequest( delete options.body; } //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'microsoftToDoOAuth2Api', options); + return this.helpers.requestOAuth2.call(this, 'microsoftToDoOAuth2Api', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -50,13 +50,13 @@ export async function microsoftApiRequestAllItems( let responseData; let uri: string | undefined; - query['$top'] = 100; + query.$top = 100; do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData['@odata.nextLink']; - if (uri && uri.includes('$top')) { - delete query['$top']; + if (uri?.includes('$top')) { + delete query.$top; } returnData.push.apply(returnData, responseData[propertyName]); } while (responseData['@odata.nextLink'] !== undefined); @@ -75,14 +75,14 @@ export async function microsoftApiRequestAllItemsSkip( const returnData: IDataObject[] = []; let responseData; - query['$top'] = 100; - query['$skip'] = 0; + query.$top = 100; + query.$skip = 0; do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); - query['$skip'] += query['$top']; + query.$skip += query.$top; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['value'].length !== 0); + } 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 924ce0f368..fb5d4dfc8c 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts @@ -154,7 +154,7 @@ export class MicrosoftToDo implements INodeType { const taskId = this.getNodeParameter('taskId', i) as string; const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItems.call( this, 'value', @@ -164,7 +164,7 @@ export class MicrosoftToDo implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call( this, 'GET', @@ -262,7 +262,7 @@ export class MicrosoftToDo implements INodeType { const taskListId = this.getNodeParameter('taskListId', i) as string; const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItems.call( this, 'value', @@ -272,7 +272,7 @@ export class MicrosoftToDo implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call( this, 'GET', @@ -354,7 +354,7 @@ export class MicrosoftToDo implements INodeType { // https://docs.microsoft.com/en-us/graph/api/todo-list-lists?view=graph-rest-1.0&tabs=http } else if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await microsoftApiRequestAllItems.call( this, 'value', @@ -364,7 +364,7 @@ export class MicrosoftToDo implements INodeType { qs, ); } else { - qs['$top'] = this.getNodeParameter('limit', i); + qs.$top = this.getNodeParameter('limit', i); responseData = await microsoftApiRequest.call( this, 'GET', diff --git a/packages/nodes-base/nodes/Mindee/GenericFunctions.ts b/packages/nodes-base/nodes/Mindee/GenericFunctions.ts index d2278c8003..46ad58220f 100644 --- a/packages/nodes-base/nodes/Mindee/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mindee/GenericFunctions.ts @@ -67,9 +67,9 @@ export function cleanDataPreviousApiVersions(predictions: IDataObject[]) { }; } else if (key === 'locale') { //@ts-ignore - newData['currency'] = data.currency; + newData.currency = data.currency; //@ts-ignore - newData['locale'] = data.value; + newData.locale = data.value; } else { newData[key] = //@ts-ignore @@ -84,9 +84,9 @@ export function cleanData(document: IDataObject) { // @ts-ignore const prediction = document.inference.prediction as IDataObject; const newData: IDataObject = {}; - newData['id'] = document.id; - newData['name'] = document.name; - newData['number_of_pages'] = document.n_pages; + newData.id = document.id; + newData.name = document.name; + newData.number_of_pages = document.n_pages; for (const key of Object.keys(prediction)) { const data = prediction[key] as IDataObject | IDataObject[]; @@ -97,9 +97,9 @@ export function cleanData(document: IDataObject) { }; } else if (key === 'locale') { //@ts-ignore - newData['currency'] = data.currency; + newData.currency = data.currency; //@ts-ignore - newData['locale'] = data.value; + newData.locale = data.value; } else { newData[key] = //@ts-ignore diff --git a/packages/nodes-base/nodes/Mindee/Mindee.node.ts b/packages/nodes-base/nodes/Mindee/Mindee.node.ts index db8a230fe8..8c0617684a 100644 --- a/packages/nodes-base/nodes/Mindee/Mindee.node.ts +++ b/packages/nodes-base/nodes/Mindee/Mindee.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IBinaryKeyData, IDataObject, INodeExecutionData, @@ -173,7 +172,7 @@ export class Mindee implements INodeType { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryPropertyName] as IBinaryData; + const binaryData = item[binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); if (binaryData === undefined) { @@ -220,7 +219,7 @@ export class Mindee implements INodeType { }, ); } - if (rawData === false) { + if (!rawData) { if (version === 1) { responseData = cleanDataPreviousApiVersions(responseData.predictions); } else if (version === 3) { @@ -244,7 +243,7 @@ export class Mindee implements INodeType { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryPropertyName] as IBinaryData; + const binaryData = item[binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); if (binaryData === undefined) { @@ -294,7 +293,7 @@ export class Mindee implements INodeType { } else { throw new NodeOperationError(this.getNode(), 'Invalid API version'); } - if (rawData === false) { + if (!rawData) { if (version === 1) { responseData = cleanDataPreviousApiVersions(responseData.predictions); } else if (version === 3) { diff --git a/packages/nodes-base/nodes/Misp/GenericFunctions.ts b/packages/nodes-base/nodes/Misp/GenericFunctions.ts index 45c5e1ca3e..740898e07e 100644 --- a/packages/nodes-base/nodes/Misp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Misp/GenericFunctions.ts @@ -40,7 +40,7 @@ export async function mispApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { // MISP API wrongly returns 403 for malformed requests if (error.statusCode === 403) { diff --git a/packages/nodes-base/nodes/Misp/Misp.node.ts b/packages/nodes-base/nodes/Misp/Misp.node.ts index 9e316631e4..263955b193 100644 --- a/packages/nodes-base/nodes/Misp/Misp.node.ts +++ b/packages/nodes-base/nodes/Misp/Misp.node.ts @@ -416,7 +416,7 @@ export class Misp implements INodeType { responseData = (await mispApiRequestAllItems.call(this, '/feeds')) as Array<{ Feed: unknown; }>; - responseData = responseData.map((i) => i.Feed); + responseData = responseData.map((entry) => entry.Feed); } else if (operation === 'update') { // ---------------------------------------- // feed: update @@ -469,7 +469,7 @@ export class Misp implements INodeType { responseData = (await mispApiRequestAllItems.call(this, '/galaxies')) as Array<{ Galaxy: unknown; }>; - responseData = responseData.map((i) => i.Galaxy); + responseData = responseData.map((entry) => entry.Galaxy); } } else if (resource === 'noticelist') { // ********************************************************************** @@ -493,7 +493,7 @@ export class Misp implements INodeType { responseData = (await mispApiRequestAllItems.call(this, '/noticelists')) as Array<{ Noticelist: unknown; }>; - responseData = responseData.map((i) => i.Noticelist); + responseData = responseData.map((entry) => entry.Noticelist); } } else if (resource === 'organisation') { // ********************************************************************** @@ -543,7 +543,7 @@ export class Misp implements INodeType { responseData = (await mispApiRequestAllItems.call(this, '/organisations')) as Array<{ Organisation: unknown; }>; - responseData = responseData.map((i) => i.Organisation); + responseData = responseData.map((entry) => entry.Organisation); } else if (operation === 'update') { // ---------------------------------------- // organisation: update @@ -678,7 +678,7 @@ export class Misp implements INodeType { responseData = (await mispApiRequestAllItems.call(this, '/admin/users')) as Array<{ User: unknown; }>; - responseData = responseData.map((i) => i.User); + responseData = responseData.map((entry) => entry.User); } else if (operation === 'update') { // ---------------------------------------- // user: update @@ -721,9 +721,11 @@ export class Misp implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', 0); - responseData = responseData.Warninglists.slice(0, limit).map((i) => i.Warninglist); + responseData = responseData.Warninglists.slice(0, limit).map( + (entry) => entry.Warninglist, + ); } else { - responseData = responseData.Warninglists.map((i) => i.Warninglist); + responseData = responseData.Warninglists.map((entry) => entry.Warninglist); } } } diff --git a/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts b/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts index 1a9a310320..dbd8bacc26 100644 --- a/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts @@ -32,9 +32,9 @@ export async function mondayComApiRequest( options.headers = { Authorization: `Bearer ${credentials.apiToken}` }; - return await this.helpers.request!(options); + return this.helpers.request!(options); } else { - return await this.helpers.requestOAuth2!.call(this, 'mondayComOAuth2Api', options); + return this.helpers.requestOAuth2!.call(this, 'mondayComOAuth2Api', options); } } catch (error) { throw new NodeApiError(this.getNode(), error); diff --git a/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts b/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts index 1c874249e0..750a74c135 100644 --- a/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts +++ b/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts @@ -323,7 +323,7 @@ export class MondayCom implements INodeType { }, }; - if (returnAll === true) { + if (returnAll) { responseData = await mondayComApiRequestAllItems.call(this, 'data.boards', body); } else { body.variables.limit = this.getNodeParameter('limit', i); @@ -589,9 +589,9 @@ export class MondayCom implements INodeType { responseData = responseData.data.delete_item; } if (operation === 'get') { - const itemIds = ( - (this.getNodeParameter('itemId', i) as string).split(',') as string[] - ).map((n) => parseInt(n, 10)); + const itemIds = (this.getNodeParameter('itemId', i) as string) + .split(',') + .map((n) => parseInt(n, 10)); const body: IGraphqlBody = { query: `query ($itemId: [Int!]){ diff --git a/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts b/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts index 67187e4278..8589504c0d 100644 --- a/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts +++ b/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts @@ -14,7 +14,12 @@ import { import { nodeDescription } from './MongoDbDescription'; -import { buildParameterizedConnString, prepareFields, prepareItems } from './GenericFunctions'; +import { + buildParameterizedConnString, + prepareFields, + prepareItems, + validateAndResolveMongoCredentials, +} from './GenericFunctions'; import { FindOneAndReplaceOptions, @@ -24,8 +29,6 @@ import { UpdateOptions, } from 'mongodb'; -import { validateAndResolveMongoCredentials } from './GenericFunctions'; - import { IMongoParametricCredentials } from './mongoDb.types'; export class MongoDb implements INodeType { @@ -59,7 +62,7 @@ export class MongoDb implements INodeType { // eslint-disable-next-line n8n-nodes-base/node-execute-block-wrong-error-thrown throw new Error(`Database "${database}" does not exist`); } - client.close(); + await client.close(); } catch (error) { return { status: 'Error', @@ -82,7 +85,7 @@ export class MongoDb implements INodeType { const client: MongoClient = await MongoClient.connect(connectionString); - const mdb = client.db(database as string); + const mdb = client.db(database); const returnItems: INodeExecutionData[] = []; let responseData: IDataObject | IDataObject[] = []; @@ -148,7 +151,7 @@ export class MongoDb implements INodeType { .collection(this.getNodeParameter('collection', 0) as string) .find(queryParameter); - const options = this.getNodeParameter('options', 0) as IDataObject; + 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); @@ -195,7 +198,7 @@ export class MongoDb implements INodeType { const filter = { [updateKey]: item[updateKey] }; if (updateKey === '_id') { filter[updateKey] = new ObjectId(item[updateKey] as string); - delete item['_id']; + delete item._id; } await mdb @@ -235,7 +238,7 @@ export class MongoDb implements INodeType { const filter = { [updateKey]: item[updateKey] }; if (updateKey === '_id') { filter[updateKey] = new ObjectId(item[updateKey] as string); - delete item['_id']; + delete item._id; } await mdb @@ -307,7 +310,7 @@ export class MongoDb implements INodeType { const filter = { [updateKey]: item[updateKey] }; if (updateKey === '_id') { filter[updateKey] = new ObjectId(item[updateKey] as string); - delete item['_id']; + delete item._id; } await mdb @@ -335,7 +338,7 @@ export class MongoDb implements INodeType { } } - client.close(); + await client.close(); const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray(responseData), diff --git a/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts b/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts index 46a9c67616..5f89e8878b 100644 --- a/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts @@ -49,7 +49,7 @@ export async function monicaCrmApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts b/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts index 1dd5bf8dc2..0896c87606 100644 --- a/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts +++ b/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts @@ -310,7 +310,7 @@ export class MonicaCrm implements INodeType { body.happened_at = (body.happened_at as string).split('T')[0]; if (typeof body.contacts === 'string') { - body.contacts = (body.contacts as string).split(','); + body.contacts = body.contacts.split(','); } const endpoint = `/activities/${activityId}`; @@ -738,7 +738,7 @@ export class MonicaCrm implements INodeType { const messageId = this.getNodeParameter('messageId', i) as string; const endpoint = `/conversations/${conversationId}/messages/${messageId}`; - const updateFields = this.getNodeParameter('updateFields', i, {}) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i, {}); const { data } = await monicaCrmApiRequest.call( this, @@ -747,7 +747,7 @@ export class MonicaCrm implements INodeType { ); const message = data.messages.filter( - (message: IDataObject) => message.id === parseInt(messageId, 10), + (entry: IDataObject) => entry.id === parseInt(messageId, 10), )[0]; const body = { diff --git a/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts b/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts index a717305ca4..05d8def576 100644 --- a/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts +++ b/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts @@ -1,8 +1,7 @@ import { get, set, unset } from 'lodash'; -import { BINARY_ENCODING } from 'n8n-core'; +import { BINARY_ENCODING, IExecuteFunctions } from 'n8n-core'; -import { IExecuteFunctions } from 'n8n-core'; import { deepCopy, IBinaryData, @@ -331,7 +330,7 @@ export class MoveBinaryData implements INodeType { let options: IDataObject; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { item = items[itemIndex]; - options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + options = this.getNodeParameter('options', itemIndex, {}); // Copy the whole JSON data as data on any level can be renamed newItem = { @@ -358,7 +357,7 @@ export class MoveBinaryData implements INodeType { let convertedValue: string; - if (setAllData === true) { + if (setAllData) { // Set the full data convertedValue = iconv.decode(buffer, encoding, { stripBOM: options.stripBOM as boolean, @@ -398,7 +397,7 @@ export class MoveBinaryData implements INodeType { const encoding = (options.encoding as string) || 'utf8'; let value: IDataObject | string = item.json; - if (convertAllData === false) { + if (!convertAllData) { const sourceKey = this.getNodeParameter('sourceKey', itemIndex) as string; value = get(item.json, sourceKey) as IDataObject; } @@ -435,7 +434,7 @@ export class MoveBinaryData implements INodeType { convertedValue.fileName = options.fileName as string; } - set(newItem.binary!, destinationKey, convertedValue); + set(newItem.binary, destinationKey, convertedValue); if (options.keepSource === true) { // JSON data does not get touched so simply reference it @@ -443,7 +442,7 @@ export class MoveBinaryData implements INodeType { } else { // JSON data will change so copy it - if (convertAllData === true) { + if (convertAllData) { // Data should not be kept and all data got converted. So simply set new as empty newItem.json = {}; } else { diff --git a/packages/nodes-base/nodes/Msg91/Msg91.node.ts b/packages/nodes-base/nodes/Msg91/Msg91.node.ts index 162907617e..c852841884 100644 --- a/packages/nodes-base/nodes/Msg91/Msg91.node.ts +++ b/packages/nodes-base/nodes/Msg91/Msg91.node.ts @@ -131,8 +131,8 @@ export class Msg91 implements INodeType { body = {}; qs = {}; - resource = this.getNodeParameter('resource', i) as string; - operation = this.getNodeParameter('operation', i) as string; + resource = this.getNodeParameter('resource', i); + operation = this.getNodeParameter('operation', i); if (resource === 'sms') { if (operation === 'send') { diff --git a/packages/nodes-base/nodes/MySql/GenericFunctions.ts b/packages/nodes-base/nodes/MySql/GenericFunctions.ts index 4702c851f6..bf9b4aa634 100644 --- a/packages/nodes-base/nodes/MySql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MySql/GenericFunctions.ts @@ -31,7 +31,7 @@ export function copyInputItems(items: INodeExecutionData[], properties: string[] }); } -export function createConnection( +export async function createConnection( credentials: ICredentialDataDecryptedObject, ): Promise { const { ssl, caCertificate, clientCertificate, clientPrivateKey, ...baseCredentials } = @@ -70,6 +70,6 @@ export async function searchTables( name: r.TABLE_NAME as string, value: r.TABLE_NAME as string, })); - connection.end(); + await connection.end(); return { results }; } diff --git a/packages/nodes-base/nodes/MySql/MySql.node.ts b/packages/nodes-base/nodes/MySql/MySql.node.ts index ac96d5f4db..34c6ea4e34 100644 --- a/packages/nodes-base/nodes/MySql/MySql.node.ts +++ b/packages/nodes-base/nodes/MySql/MySql.node.ts @@ -256,7 +256,7 @@ export class MySql implements INodeType { const credentials = credential.data as ICredentialDataDecryptedObject; try { const connection = await createConnection(credentials); - connection.end(); + await connection.end(); } catch (error) { return { status: 'Error', @@ -287,7 +287,7 @@ export class MySql implements INodeType { // ---------------------------------- try { - const queryQueue = items.map((item, index) => { + const queryQueue = items.map(async (item, index) => { const rawQuery = this.getNodeParameter('query', index) as string; return connection.query(rawQuery); @@ -327,7 +327,7 @@ export class MySql implements INodeType { const columns = columnString.split(',').map((column) => column.trim()); const insertItems = copyInputItems(items, columns); const insertPlaceholder = `(${columns.map((_column) => '?').join(',')})`; - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); const insertIgnore = options.ignore as boolean; const insertPriority = options.priority as string; @@ -371,7 +371,7 @@ export class MySql implements INodeType { const updateSQL = `UPDATE ${table} SET ${columns .map((column) => `${column} = ?`) .join(',')} WHERE ${updateKey} = ?;`; - const queryQueue = updateItems.map((item) => + const queryQueue = updateItems.map(async (item) => connection.query(updateSQL, Object.values(item).concat(item[updateKey])), ); const queryResult = await Promise.all(queryQueue); diff --git a/packages/nodes-base/nodes/N8n/GenericFunctions.ts b/packages/nodes-base/nodes/N8n/GenericFunctions.ts index 9139136473..1cedeedc9d 100644 --- a/packages/nodes-base/nodes/N8n/GenericFunctions.ts +++ b/packages/nodes-base/nodes/N8n/GenericFunctions.ts @@ -44,7 +44,7 @@ export async function apiRequest( }; try { - return await this.helpers.requestWithAuthentication.call(this, 'n8nApi', options); + return this.helpers.requestWithAuthentication.call(this, 'n8nApi', options); } catch (error) { if (error instanceof NodeApiError) { throw error; @@ -104,6 +104,14 @@ export const getCursorPaginator = () => { let nextCursor: string | undefined = undefined; const returnAll = this.getNodeParameter('returnAll', true) as boolean; + const extractItems = (page: INodeExecutionData) => { + const items = page.json.data as IDataObject[]; + if (items) { + // Extract the items themselves + executions = executions.concat(items.map((item) => ({ json: item }))); + } + }; + do { requestOptions.options.qs.cursor = nextCursor; responseData = await this.makeRoutingRequest(requestOptions); @@ -112,13 +120,7 @@ export const getCursorPaginator = () => { const lastItem = responseData[responseData.length - 1].json; nextCursor = lastItem.nextCursor as string | undefined; - responseData.forEach((page) => { - const items = page.json.data as IDataObject[]; - if (items) { - // Extract the items themselves - executions = executions.concat(items.map((item) => ({ json: item }))); - } - }); + responseData.forEach(extractItems); // If we don't return all, just return the first page } while (returnAll && nextCursor); diff --git a/packages/nodes-base/nodes/N8nTrainingCustomerDatastore/N8nTrainingCustomerDatastore.node.ts b/packages/nodes-base/nodes/N8nTrainingCustomerDatastore/N8nTrainingCustomerDatastore.node.ts index 20d39ce0ae..a64d139d50 100644 --- a/packages/nodes-base/nodes/N8nTrainingCustomerDatastore/N8nTrainingCustomerDatastore.node.ts +++ b/packages/nodes-base/nodes/N8nTrainingCustomerDatastore/N8nTrainingCustomerDatastore.node.ts @@ -124,7 +124,7 @@ export class N8nTrainingCustomerDatastore implements INodeType { if (operation === 'getAllPeople') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = data; } else { const limit = this.getNodeParameter('limit', i); diff --git a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts index 0225964150..eee6487f71 100644 --- a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts @@ -14,7 +14,7 @@ export async function nasaApiRequest( ): Promise { const credentials = await this.getCredentials('nasaApi'); - qs.api_key = credentials['api_key'] as string; + qs.api_key = credentials.api_key as string; const options: OptionsWithUri = { method, diff --git a/packages/nodes-base/nodes/Nasa/Nasa.node.ts b/packages/nodes-base/nodes/Nasa/Nasa.node.ts index 872b536b12..2e6913cc21 100644 --- a/packages/nodes-base/nodes/Nasa/Nasa.node.ts +++ b/packages/nodes-base/nodes/Nasa/Nasa.node.ts @@ -916,7 +916,7 @@ export class Nasa implements INodeType { if (operation === 'getAll') { returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === false) { + if (!returnAll) { qs.size = this.getNodeParameter('limit', 0); } @@ -1071,7 +1071,7 @@ export class Nasa implements INodeType { if (resource === 'astronomyPictureOfTheDay') { download = this.getNodeParameter('download', 0); - if (download === true) { + if (download) { const binaryProperty = this.getNodeParameter('binaryPropertyName', i) as string; const data = await nasaApiRequest.call( @@ -1115,11 +1115,7 @@ export class Nasa implements INodeType { if (this.continueOnFail()) { if (resource === 'earthImagery' && operation === 'get') { items[i].json = { error: error.message }; - } else if ( - resource === 'astronomyPictureOfTheDay' && - operation === 'get' && - download === true - ) { + } else if (resource === 'astronomyPictureOfTheDay' && operation === 'get' && download) { items[i].json = { error: error.message }; } else { const executionErrorData = this.helpers.constructExecutionMetaData( @@ -1136,11 +1132,7 @@ export class Nasa implements INodeType { if (resource === 'earthImagery' && operation === 'get') { return this.prepareOutputData(items); - } else if ( - resource === 'astronomyPictureOfTheDay' && - operation === 'get' && - download === true - ) { + } else if (resource === 'astronomyPictureOfTheDay' && operation === 'get' && download) { return this.prepareOutputData(items); } else { return this.prepareOutputData(returnData); diff --git a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts index f5756ebb8d..37930fe6f7 100644 --- a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts @@ -41,7 +41,7 @@ export async function netlifyApiRequest( try { const credentials = await this.getCredentials('netlifyApi'); - options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; + options.headers!.Authorization = `Bearer ${credentials.accessToken}`; return await this.helpers.request!(options); } catch (error) { diff --git a/packages/nodes-base/nodes/Netlify/Netlify.node.ts b/packages/nodes-base/nodes/Netlify/Netlify.node.ts index 7947b289bd..80abe8beb5 100644 --- a/packages/nodes-base/nodes/Netlify/Netlify.node.ts +++ b/packages/nodes-base/nodes/Netlify/Netlify.node.ts @@ -136,7 +136,7 @@ export class Netlify implements INodeType { if (operation === 'getAll') { const siteId = this.getNodeParameter('siteId', i); const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await netlifyRequestAllItems.call( this, 'GET', @@ -167,7 +167,7 @@ export class Netlify implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await netlifyRequestAllItems.call( this, 'GET', diff --git a/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts b/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts index ddc9963667..5869de66ef 100644 --- a/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts +++ b/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts @@ -202,7 +202,7 @@ export class NetlifyTrigger implements INodeType { const event = this.getNodeParameter('event') as string; let response = req.body; - if (simple === true && event === 'submissionCreated') { + if (simple && event === 'submissionCreated') { response = response.data; } diff --git a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts index 824114fee6..4c9db32e7b 100644 --- a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts +++ b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts @@ -1,11 +1,12 @@ import { IExecuteFunctions } from 'n8n-core'; -import { IBinaryKeyData, NodeApiError } from 'n8n-workflow'; import { + IBinaryKeyData, IDataObject, INodeExecutionData, INodeType, INodeTypeDescription, + NodeApiError, NodeOperationError, } from 'n8n-workflow'; @@ -1076,9 +1077,7 @@ export class NextCloud implements INodeType { const userid = this.getNodeParameter('userId', i) as string; endpoint = `ocs/v1.php/cloud/users/${userid}`; - body = Object.entries( - (this.getNodeParameter('updateFields', i) as IDataObject).field as IDataObject, - ) + body = Object.entries(this.getNodeParameter('updateFields', i).field as IDataObject) .map((entry) => { const [key, value] = entry; return `${key}=${value}`; @@ -1152,6 +1151,7 @@ export class NextCloud implements INodeType { 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) => { if (err) { @@ -1168,9 +1168,10 @@ export class NextCloud implements INodeType { }); }); - returnData.push(jsonResponseData as IDataObject); + returnData.push(jsonResponseData); } else if (resource === 'user') { 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) => { if (err) { @@ -1191,8 +1192,9 @@ export class NextCloud implements INodeType { }); }); - returnData.push(jsonResponseData as IDataObject); + returnData.push(jsonResponseData); } else { + // eslint-disable-next-line @typescript-eslint/no-loop-func const jsonResponseData: IDataObject[] = await new Promise((resolve, reject) => { parseString(responseData, { explicitArray: false }, (err, data) => { if (err) { @@ -1216,6 +1218,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) => { if (err) { @@ -1242,7 +1245,7 @@ export class NextCloud implements INodeType { if (Array.isArray(jsonResponseData['d:multistatus']['d:response'])) { // @ts-ignore for (const item of jsonResponseData['d:multistatus']['d:response']) { - if (skippedFirst === false) { + if (!skippedFirst) { skippedFirst = true; continue; } @@ -1272,7 +1275,7 @@ export class NextCloud implements INodeType { // @ts-ignore newItem.eTag = props['d:getetag'].slice(1, -1); - returnData.push(newItem as IDataObject); + returnData.push(newItem); } } } diff --git a/packages/nodes-base/nodes/NoOp/NoOp.node.ts b/packages/nodes-base/nodes/NoOp/NoOp.node.ts index 2835a33781..804531c7e6 100644 --- a/packages/nodes-base/nodes/NoOp/NoOp.node.ts +++ b/packages/nodes-base/nodes/NoOp/NoOp.node.ts @@ -18,7 +18,7 @@ export class NoOp implements INodeType { properties: [], }; - execute(this: IExecuteFunctions): Promise { + async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); return this.prepareOutputData(items); diff --git a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts index 0c390ec1c3..30656a7f86 100644 --- a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts @@ -75,7 +75,7 @@ export async function apiRequestAllItems( body: IDataObject, query?: IDataObject, ): Promise { - const version = this.getNode().typeVersion as number; + const version = this.getNode().typeVersion; if (query === undefined) { query = {}; @@ -108,8 +108,8 @@ export async function downloadRecordAttachments( element.json = record as unknown as IDataObject; for (const fieldName of fieldNames) { if (record[fieldName]) { - for (const [index, attachment] of ( - jsonParse(record[fieldName] as string) as IAttachment[] + for (const [index, attachment] of jsonParse( + record[fieldName] as string, ).entries()) { const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, diff --git a/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts b/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts index 7c659ae706..93a660640a 100644 --- a/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts +++ b/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts @@ -2,7 +2,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IDataObject, ILoadOptionsFunctions, INodeExecutionData, @@ -273,7 +272,7 @@ export class NocoDB implements INodeType { { itemIndex: i }, ); } - const binaryData = items[i].binary![binaryPropertyName] as IBinaryData; + const binaryData = items[i].binary![binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); const formData = { @@ -291,7 +290,6 @@ export class NocoDB implements INodeType { args: {}, }), }; - const qs = { project_id: projectId }; let postUrl = ''; if (version === 1) { @@ -300,9 +298,17 @@ export class NocoDB implements INodeType { postUrl = '/api/v1/db/storage/upload'; } - responseData = await apiRequest.call(this, 'POST', postUrl, {}, qs, undefined, { - formData, - }); + responseData = await apiRequest.call( + this, + 'POST', + postUrl, + {}, + { project_id: projectId }, + undefined, + { + formData, + }, + ); newItem[field.fieldName] = JSON.stringify([responseData]); } } @@ -387,8 +393,8 @@ export class NocoDB implements INodeType { endPoint = `/api/v1/db/data/noco/${projectId}/${table}`; } - returnAll = this.getNodeParameter('returnAll', 0) as boolean; - qs = this.getNodeParameter('options', i, {}) as IDataObject; + returnAll = this.getNodeParameter('returnAll', 0); + qs = this.getNodeParameter('options', i, {}); if (qs.sort) { const properties = (qs.sort as IDataObject).property as Array<{ @@ -404,7 +410,7 @@ export class NocoDB implements INodeType { qs.fields = (qs.fields as IDataObject[]).join(','); } - if (returnAll === true) { + if (returnAll) { responseData = await apiRequestAllItems.call(this, requestMethod, endPoint, {}, qs); } else { qs.limit = this.getNodeParameter('limit', 0); @@ -420,7 +426,7 @@ export class NocoDB implements INodeType { ); returnData.push(...executionData); - if (downloadAttachments === true) { + if (downloadAttachments) { const downloadFieldNames = ( this.getNodeParameter('downloadFieldNames', 0) as string ).split(','); @@ -481,7 +487,7 @@ export class NocoDB implements INodeType { const downloadAttachments = this.getNodeParameter('downloadAttachments', i) as boolean; - if (downloadAttachments === true) { + if (downloadAttachments) { const downloadFieldNames = ( this.getNodeParameter('downloadFieldNames', i) as string ).split(','); @@ -526,7 +532,7 @@ export class NocoDB implements INodeType { } if (operation === 'update') { - let requestMethod = 'PATCH'; + requestMethod = 'PATCH'; if (version === 1) { endPoint = `/nc/${projectId}/api/v1/${table}/bulk`; @@ -576,7 +582,7 @@ export class NocoDB implements INodeType { { itemIndex: i }, ); } - const binaryData = items[i].binary![binaryPropertyName] as IBinaryData; + const binaryData = items[i].binary![binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); const formData = { @@ -594,16 +600,23 @@ export class NocoDB implements INodeType { args: {}, }), }; - const qs = { project_id: projectId }; let postUrl = ''; if (version === 1) { postUrl = '/dashboard'; } else if (version === 2) { postUrl = '/api/v1/db/storage/upload'; } - responseData = await apiRequest.call(this, 'POST', postUrl, {}, qs, undefined, { - formData, - }); + responseData = await apiRequest.call( + this, + 'POST', + postUrl, + {}, + { project_id: projectId }, + undefined, + { + formData, + }, + ); newItem[field.fieldName] = JSON.stringify([responseData]); } } diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index b4c89db131..5cd915cb5f 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -17,7 +17,7 @@ import { NodeApiError, } from 'n8n-workflow'; -import { camelCase, capitalCase } from 'change-case'; +import { camelCase, capitalCase, snakeCase } from 'change-case'; import { filters } from './Filters'; @@ -25,8 +25,6 @@ import moment from 'moment-timezone'; import { validate as uuidValidate } from 'uuid'; -import { snakeCase } from 'change-case'; - const apiVersion: { [key: number]: string } = { 1: '2021-05-13', 2: '2021-08-16', @@ -90,9 +88,9 @@ export async function notionApiRequestAllItems( responseData = await notionApiRequest.call(this, method, endpoint, body, query); const { next_cursor } = responseData; if (resource === 'block' || resource === 'user') { - query['start_cursor'] = next_cursor; + query.start_cursor = next_cursor; } else { - body['start_cursor'] = next_cursor; + body.start_cursor = next_cursor; } returnData.push.apply(returnData, responseData[propertyName]); if (query.limit && query.limit <= returnData.length) { @@ -165,7 +163,7 @@ export function formatText(content: string) { } function getLink(text: { textLink: string; isLink: boolean }) { - if (text.isLink === true && text.textLink !== '') { + if (text.isLink && text.textLink !== '') { return { link: { url: text.textLink, @@ -209,10 +207,9 @@ function getTexts( type: 'mention', mention: { type: text.mentionType, - [text.mentionType]: - text.range === true - ? { start: text.dateStart, end: text.dateEnd } - : { start: text.date, end: null }, + [text.mentionType]: text.range + ? { start: text.dateStart, end: text.dateEnd } + : { start: text.date, end: null }, }, annotations: text.annotationUi, }); @@ -299,8 +296,8 @@ function getPropertyKeyValue(value: any, type: string, timezone: string, version ? multiSelectValue : multiSelectValue.split(',').map((v: string) => v.trim()) ) - - .filter((value: any) => value !== null) + // tslint:disable-next-line: no-any + .filter((entry: any) => entry !== null) .map((option: string) => (!uuidValidate(option) ? { name: option } : { id: option })), }; break; @@ -382,7 +379,7 @@ function getPropertyKeyValue(value: any, type: string, timezone: string, version } function getDateFormat(includeTime: boolean) { - if (includeTime === false) { + if (!includeTime) { return 'yyyy-MM-DD'; } return ''; @@ -430,8 +427,9 @@ export function mapSorting( }); } -export function mapFilters(filters: IDataObject[], timezone: string) { - return filters.reduce((obj, value: { [key: string]: any }) => { +export function mapFilters(filtersList: IDataObject[], timezone: string) { + // tslint:disable-next-line: no-any + return filtersList.reduce((obj, value: { [key: string]: any }) => { let key = getNameAndType(value.key).type; let valuePropertyName = @@ -460,11 +458,11 @@ export function mapFilters(filters: IDataObject[], timezone: string) { } if (value.type === 'formula') { - const valuePropertyName = value[`${camelCase(value.returnType)}Value`]; + const vpropertyName = value[`${camelCase(value.returnType)}Value`]; return Object.assign(obj, { ['property']: getNameAndType(value.key).name, - [key]: { [value.returnType]: { [`${value.condition}`]: valuePropertyName } }, + [key]: { [value.returnType]: { [`${value.condition}`]: vpropertyName } }, }); } @@ -498,7 +496,7 @@ function simplifyProperty(property: any) { 'date', ].includes(property.type) ) { - result = property[type] as any; + result = property[type]; } else if (['created_by', 'last_edited_by', 'select'].includes(property.type)) { result = property[type] ? property[type].name : null; } else if (['people'].includes(property.type)) { @@ -692,9 +690,9 @@ export function getConditions() { type: [type], }, } as IDisplayOptions, - options: (typeConditions[types[type]] as string[]).map((type: string) => ({ - name: capitalCase(type), - value: type, + options: typeConditions[types[type]].map((entry: string) => ({ + name: capitalCase(entry), + value: entry, })), default: '', description: 'The value of the property to filter by', @@ -726,7 +724,7 @@ export function getConditions() { returnType: [key], }, } as IDisplayOptions, - options: formula[key].map((key: string) => ({ name: capitalCase(key), value: key })), + options: formula[key].map((entry: string) => ({ name: capitalCase(entry), value: entry })), default: '', description: 'The value of the property to filter by', } as INodeProperties); @@ -736,7 +734,8 @@ export function getConditions() { } // 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: [{ properties: { [key: string]: any | { id: string; type: string; files: [{ external: { url: string } } | { file: { url: string } }] } } }]): Promise { // tslint:disable-line:no-any + const elements: INodeExecutionData[] = []; for (const record of records) { const element: INodeExecutionData = { json: {}, binary: {} }; diff --git a/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts b/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts index d81f2c6048..568a2811b2 100644 --- a/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts +++ b/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts @@ -202,7 +202,7 @@ export class NotionTrigger implements INodeType { ); if (this.getMode() === 'manual') { - if (simple === true) { + if (simple) { data = simplifyObjects(data, false, 1); } if (Array.isArray(data) && data.length) { @@ -226,12 +226,12 @@ export class NotionTrigger implements INodeType { records.push(...results); hasMore = has_more; if (next_cursor !== null) { - body['start_cursor'] = next_cursor; + body.start_cursor = next_cursor; } // Only stop when we reach records strictly before last recorded time to be sure we catch records from the same minute } while ( !moment(records[records.length - 1][sortProperty] as string).isBefore(lastTimeChecked) && - hasMore === true + hasMore ); // Filter out already processed left over records: @@ -255,7 +255,7 @@ export class NotionTrigger implements INodeType { webhookData.possibleDuplicates = undefined; } - if (simple === true) { + if (simple) { records = simplifyObjects(records, false, 1); } diff --git a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts index 752890bc73..f579c96fa5 100644 --- a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts +++ b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts @@ -327,7 +327,7 @@ export class NotionV1 implements INodeType { body, ); } else { - body['page_size'] = this.getNodeParameter('limit', i); + body.page_size = this.getNodeParameter('limit', i); responseData = await notionApiRequest.call(this, 'POST', `/search`, body); responseData = responseData.results; } @@ -350,7 +350,7 @@ export class NotionV1 implements INodeType { parent: {}, properties: {}, }; - body.parent['database_id'] = this.getNodeParameter('databaseId', i, '', { + body.parent.database_id = this.getNodeParameter('databaseId', i, '', { extractValue: true, }) as string; const properties = this.getNodeParameter( @@ -365,7 +365,7 @@ export class NotionV1 implements INodeType { extractDatabaseMentionRLC(blockValues); body.children = formatBlocks(blockValues); responseData = await notionApiRequest.call(this, 'POST', '/pages', body); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, false, 1); } @@ -390,7 +390,7 @@ export class NotionV1 implements INodeType { filter: {}, }; if (filters.singleCondition) { - body['filter'] = mapFilters([filters.singleCondition] as IDataObject[], timezone); + body.filter = mapFilters([filters.singleCondition] as IDataObject[], timezone); } if (filters.multipleCondition) { const { or, and } = (filters.multipleCondition as IDataObject).condition as IDataObject; @@ -410,7 +410,7 @@ export class NotionV1 implements INodeType { } if (sort) { //@ts-expect-error - body['sorts'] = mapSorting(sort); + body.sorts = mapSorting(sort); } if (returnAll) { responseData = await notionApiRequestAllItems.call( @@ -432,7 +432,7 @@ export class NotionV1 implements INodeType { ); responseData = responseData.results; } - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, false, 1); } @@ -463,7 +463,7 @@ export class NotionV1 implements INodeType { body.properties = mapProperties(properties, timezone) as IDataObject; } responseData = await notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, body); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, false, 1); } @@ -518,7 +518,7 @@ export class NotionV1 implements INodeType { parent: {}, properties: {}, }; - body.parent['page_id'] = extractPageId( + body.parent.page_id = extractPageId( this.getNodeParameter('pageId', i, '', { extractValue: true }) as string, ); body.properties = formatTitle(this.getNodeParameter('title', i) as string); @@ -526,7 +526,7 @@ export class NotionV1 implements INodeType { extractDatabaseMentionRLC(blockValues); body.children = formatBlocks(blockValues); responseData = await notionApiRequest.call(this, 'POST', '/pages', body); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, false, 1); } @@ -543,7 +543,7 @@ export class NotionV1 implements INodeType { const pageId = extractPageId(this.getNodeParameter('pageId', i) as string); const simple = this.getNodeParameter('simple', i) as boolean; responseData = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, false, 1); } @@ -564,17 +564,17 @@ export class NotionV1 implements INodeType { const body: IDataObject = {}; if (text) { - body['query'] = text; + body.query = text; } if (options.filter) { - const filter = (((options.filter as IDataObject) || {}).filters as IDataObject[]) || []; - body['filter'] = filter; + const filter = ((options.filter as IDataObject)?.filters as IDataObject[]) || []; + body.filter = filter; } if (options.sort) { - const sort = (((options.sort as IDataObject) || {}).sortValue as IDataObject) || {}; - body['sort'] = sort; + const sort = ((options.sort as IDataObject)?.sortValue as IDataObject) || {}; + body.sort = sort; } if (returnAll) { responseData = await notionApiRequestAllItems.call( @@ -596,7 +596,7 @@ export class NotionV1 implements INodeType { responseData = responseData.splice(0, qs.limit); } - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, false, 1); } diff --git a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts index f1e25b74dd..3bbd5ede92 100644 --- a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts +++ b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts @@ -318,7 +318,7 @@ export class NotionV2 implements INodeType { this.getNodeParameter('databaseId', i, '', { extractValue: true }) as string, ); responseData = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, download)[0]; } @@ -346,11 +346,11 @@ export class NotionV2 implements INodeType { body, ); } else { - body['page_size'] = this.getNodeParameter('limit', i); + body.page_size = this.getNodeParameter('limit', i); responseData = await notionApiRequest.call(this, 'POST', `/search`, body); responseData = responseData.results; } - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, download); } @@ -376,11 +376,11 @@ export class NotionV2 implements INodeType { }; if (text) { - body['query'] = text; + body.query = text; } if (options.sort) { - const sort = (((options.sort as IDataObject) || {}).sortValue as IDataObject) || {}; - body['sort'] = sort; + const sort = ((options.sort as IDataObject)?.sortValue as IDataObject) || {}; + body.sort = sort; } if (returnAll) { responseData = await notionApiRequestAllItems.call( @@ -402,7 +402,7 @@ export class NotionV2 implements INodeType { responseData = responseData.splice(0, qs.limit); } - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, download); } @@ -446,25 +446,25 @@ export class NotionV2 implements INodeType { ], }; } - body.parent['database_id'] = this.getNodeParameter('databaseId', i, '', { + body.parent.database_id = this.getNodeParameter('databaseId', i, '', { extractValue: true, }) as string; - const properties = this.getNodeParameter( + const propertiesValues = this.getNodeParameter( 'propertiesUi.propertyValues', i, [], ) as IDataObject[]; - if (properties.length !== 0) { + if (propertiesValues.length !== 0) { body.properties = Object.assign( body.properties, - mapProperties(properties, timezone, 2) as IDataObject, + mapProperties(propertiesValues, timezone, 2) as IDataObject, ); } const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]; extractDatabaseMentionRLC(blockValues); body.children = formatBlocks(blockValues); responseData = await notionApiRequest.call(this, 'POST', '/pages', body); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData); } @@ -483,7 +483,7 @@ export class NotionV2 implements INodeType { ); const simple = this.getNodeParameter('simple', i) as boolean; responseData = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, download); } @@ -537,7 +537,7 @@ export class NotionV2 implements INodeType { } if (sort) { //@ts-expect-error - body['sorts'] = mapSorting(sort); + body.sorts = mapSorting(sort); } if (returnAll) { responseData = await notionApiRequestAllItems.call( @@ -559,10 +559,10 @@ export class NotionV2 implements INodeType { ); responseData = responseData.results; } - if (download === true) { + if (download) { responseData = await downloadFiles.call(this, responseData); } - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, download); } @@ -593,7 +593,7 @@ export class NotionV2 implements INodeType { body.properties = mapProperties(properties, timezone, 2) as IDataObject; } responseData = await notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, body); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, false); } @@ -649,7 +649,7 @@ export class NotionV2 implements INodeType { responseData = await notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, { archived: true, }); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, download); } @@ -669,7 +669,7 @@ export class NotionV2 implements INodeType { parent: {}, properties: {}, }; - body.parent['page_id'] = extractPageId( + body.parent.page_id = extractPageId( this.getNodeParameter('pageId', i, '', { extractValue: true }) as string, ); body.properties = formatTitle(this.getNodeParameter('title', i) as string); @@ -677,7 +677,7 @@ export class NotionV2 implements INodeType { extractDatabaseMentionRLC(blockValues); body.children = formatBlocks(blockValues); responseData = await notionApiRequest.call(this, 'POST', '/pages', body); - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, download); } @@ -698,15 +698,15 @@ export class NotionV2 implements INodeType { const body: IDataObject = {}; if (text) { - body['query'] = text; + body.query = text; } if (options.filter) { - const filter = (((options.filter as IDataObject) || {}).filters as IDataObject[]) || []; - body['filter'] = filter; + const filter = ((options.filter as IDataObject)?.filters as IDataObject[]) || []; + body.filter = filter; } if (options.sort) { - const sort = (((options.sort as IDataObject) || {}).sortValue as IDataObject) || {}; - body['sort'] = sort; + const sort = ((options.sort as IDataObject)?.sortValue as IDataObject) || {}; + body.sort = sort; } if (returnAll) { responseData = await notionApiRequestAllItems.call( @@ -728,7 +728,7 @@ export class NotionV2 implements INodeType { responseData = responseData.splice(0, qs.limit); } - if (simple === true) { + if (simple) { responseData = simplifyObjects(responseData, download); } @@ -741,7 +741,7 @@ export class NotionV2 implements INodeType { } } - if (download === true) { + if (download) { const rawData = returnData.map((data) => data.json); return this.prepareOutputData(rawData as INodeExecutionData[]); } diff --git a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts index 41254f043e..0455b0ed5a 100644 --- a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts @@ -42,7 +42,7 @@ export async function onfleetApiRequest( }; try { //@ts-ignore - return await this.helpers.request(options); + return this.helpers.request(options); } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } @@ -63,9 +63,9 @@ export async function onfleetApiRequestAllItems( do { responseData = await onfleetApiRequest.call(this, method, endpoint, body, query); - query.lastId = responseData['lastId']; + query.lastId = responseData.lastId; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['lastId'] !== undefined); + } 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 ec1516cbc4..cda4c7686f 100644 --- a/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts +++ b/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts @@ -179,6 +179,7 @@ export class Onfleet implements INodeType { const operation = this.getNodeParameter('operation', 0); const items = this.getInputData(); + // eslint-disable-next-line @typescript-eslint/ban-types const operations: { [key: string]: Function } = { task: OnfleetMethods.executeTaskOperations, destination: OnfleetMethods.executeDestinationOperations, diff --git a/packages/nodes-base/nodes/Onfleet/Onfleet.ts b/packages/nodes-base/nodes/Onfleet/Onfleet.ts index 1d74c10ffb..e6600c7881 100644 --- a/packages/nodes-base/nodes/Onfleet/Onfleet.ts +++ b/packages/nodes-base/nodes/Onfleet/Onfleet.ts @@ -141,16 +141,10 @@ export class Onfleet { addressCity as string, addressCountry as string, additionalFields as IDataObject, - ) as OnfleetDestination; + ); } else { - let unparsed, - address, - addressNumber, - addressStreet, - addressCity, - addressCountry, - additionalFields; - unparsed = this.getNodeParameter('unparsed', item) as boolean; + let address, addressNumber, addressStreet, addressCity, addressCountry; + const unparsed = this.getNodeParameter('unparsed', item) as boolean; if (unparsed) { address = this.getNodeParameter('address', item) as string; } else { @@ -159,7 +153,7 @@ export class Onfleet { addressCity = this.getNodeParameter('addressCity', item) as string; addressCountry = this.getNodeParameter('addressCountry', item) as string; } - additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; return formatAddress( unparsed, @@ -169,7 +163,7 @@ export class Onfleet { addressCity, addressCountry, additionalFields, - ) as OnfleetDestination; + ); } } return null; @@ -191,7 +185,7 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ const name = this.getNodeParameter('name', item) as string; const email = this.getNodeParameter('email', item) as string; - const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', item); const adminData: OnfleetAdmins = { name, email }; // Adding additional fields @@ -202,7 +196,7 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ /* Get fields for update admin */ /* -------------------------------------------------------------------------- */ - const updateFields = this.getNodeParameter('updateFields', item) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', item); const adminData: OnfleetAdmins = {}; if (!Object.keys(updateFields).length) { throw new NodeOperationError(this.getNode(), 'Select at least one field to be updated'); @@ -235,7 +229,7 @@ export class Onfleet { true, ) as OnfleetDestination; const name = this.getNodeParameter('name', item) as string; - const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', item); const hubData: OnfleetHubs = { name, ...destination }; @@ -253,7 +247,7 @@ export class Onfleet { const hubData: OnfleetHubs = { ...destination }; // Adding additional fields - const updateFields = this.getNodeParameter('updateFields', item) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', item); if (!Object.keys(updateFields).length) { throw new NodeOperationError(this.getNode(), 'Select at least one field to be updated'); @@ -285,7 +279,7 @@ export class Onfleet { const workerData: OnfleetWorker = { name, phone, teams }; // Adding additional fields - const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', item); if (additionalFields.vehicle) { const { vehicleProperties } = additionalFields.vehicle as IDataObject; @@ -304,7 +298,7 @@ export class Onfleet { const workerData: OnfleetWorker = {}; // Adding additional fields - const updateFields = this.getNodeParameter('updateFields', item) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', item); if (!Object.keys(updateFields).length) { throw new NodeOperationError(this.getNode(), 'Select at least one field to be updated'); @@ -313,7 +307,7 @@ export class Onfleet { Object.assign(workerData, updateFields); return workerData; } else if (operation === 'get') { - const options = this.getNodeParameter('options', item, {}) as IDataObject; + const options = this.getNodeParameter('options', item, {}); const workerFilter: OnfleetWorkerFilter = {}; if (options.filter) { options.filter = (options.filter as string[]).join(','); @@ -328,8 +322,8 @@ export class Onfleet { /* Get fields for get and getAll workers */ /* -------------------------------------------------------------------------- */ - const options = this.getNodeParameter('options', item, {}) as IDataObject; - const filters = this.getNodeParameter('filters', item, {}) as IDataObject; + const options = this.getNodeParameter('options', item, {}); + const filters = this.getNodeParameter('filters', item, {}); const workerFilter: OnfleetWorkerFilter = {}; if (filters.states) { @@ -354,7 +348,7 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ const { scheduleProperties } = this.getNodeParameter('schedule', item) as IDataObject; const entries = ((scheduleProperties as IDataObject[]) || []).map((entry) => { - const { timezone, date, shifts } = entry as IDataObject; + const { timezone, date, shifts } = entry; const { shiftsProperties } = shifts as IDataObject; return { timezone: timezone as string, @@ -364,7 +358,7 @@ export class Onfleet { new Date(end as Date).getTime(), ]), } as OnfleetWorkerScheduleEntry; - }) as OnfleetWorkerScheduleEntry[]; + }); return { entries } as OnfleetWorkerSchedule; } return null; @@ -387,7 +381,7 @@ export class Onfleet { const url = this.getNodeParameter('url', item) as string; const name = this.getNodeParameter('name', item) as string; const trigger = this.getNodeParameter('trigger', item) as number; - const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', item); const webhookData: OnfleetWebhook = { url, name, trigger }; // Adding additional fields @@ -470,7 +464,7 @@ export class Onfleet { const phone = this.getNodeParameter('recipientPhone', item) as string; const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; const options = this.getNodeParameter('options', item) as IDataObject; - return Onfleet.formatRecipient(name, phone, additionalFields, options) as OnfleetRecipient; + return Onfleet.formatRecipient(name, phone, additionalFields, options); } } else if (operation === 'update') { /* -------------------------------------------------------------------------- */ @@ -576,8 +570,7 @@ export class Onfleet { } // Adding overrides data - const { notes, pickupTask, serviceTime, completeAfter, completeBefore } = - overrideFields as IDataObject; + const { notes, pickupTask, serviceTime, completeAfter, completeBefore } = overrideFields; const overridesData = {} as OnfleetCloneOverrideTaskOptions; if (notes) overridesData.notes = notes as string; @@ -651,7 +644,7 @@ export class Onfleet { const name = this.getNodeParameter('name', item) as string; const workers = this.getNodeParameter('workers', item) as string[]; const managers = this.getNodeParameter('managers', item) as string[]; - const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', item); const teamData: OnfleetTeams = { name, workers, managers }; // Adding additional fields @@ -664,7 +657,7 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ const teamData: OnfleetTeams = {}; // Adding additional fields - const updateFields = this.getNodeParameter('updateFields', item) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', item); if (!Object.keys(updateFields).length) { throw new NodeOperationError(this.getNode(), 'Select at least one field to be updated'); @@ -680,7 +673,7 @@ export class Onfleet { dropOff = {}, pickUp = {}, ...additionalFields - } = this.getNodeParameter('filters', item) as IDataObject; + } = this.getNodeParameter('filters', item); const { dropOffProperties = {} } = dropOff as IDataObject; const { pickUpProperties = {} } = pickUp as IDataObject; const hasPickUp = pickUp && Object.keys(pickUpProperties as IDataObject).length > 0; @@ -726,7 +719,7 @@ export class Onfleet { taskTimeWindow = {}, endingRoute = {}, ...additionalFields - } = this.getNodeParameter('additionalFields', item) as IDataObject; + } = this.getNodeParameter('additionalFields', item); const { endingRouteProperties = {} } = endingRoute as IDataObject; const { scheduleTimeWindowProperties = {} } = scheduleTimeWindow as IDataObject; const { taskTimeWindowProperties = {} } = taskTimeWindow as IDataObject; @@ -1126,7 +1119,7 @@ export class Onfleet { const returnAll = this.getNodeParameter('returnAll', 0, false); let hubs = await onfleetApiRequest.call(this, 'GET', resource); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); hubs = hubs.slice(0, limit); } @@ -1180,7 +1173,7 @@ export class Onfleet { /* Get all workers */ /* -------------------------------------------------------------------------- */ const byLocation = this.getNodeParameter('byLocation', index) as boolean; - const returnAll = this.getNodeParameter('returnAll', index, false) as boolean; + const returnAll = this.getNodeParameter('returnAll', index, false); let workers; if (byLocation) { @@ -1403,7 +1396,7 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ /* Get all teams */ /* -------------------------------------------------------------------------- */ - const returnAll = this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll = this.getNodeParameter('returnAll', 0, false); let teams = await onfleetApiRequest.call(this, 'GET', resource); if (!returnAll) { const limit = this.getNodeParameter('limit', 0); diff --git a/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts b/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts index f0991209bb..61bb54cdeb 100644 --- a/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts +++ b/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts @@ -56,7 +56,7 @@ export class OnfleetTrigger implements INodeType { webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { - const webhookData = this.getWorkflowStaticData('node') as IDataObject; + const webhookData = this.getWorkflowStaticData('node'); const webhookUrl = this.getNodeWebhookUrl('default') as string; // Webhook got created before so check if it still exists @@ -75,7 +75,7 @@ export class OnfleetTrigger implements INodeType { async create(this: IHookFunctions): Promise { const { name = '' } = this.getNodeParameter('additionalFields') as IDataObject; const triggerOn = this.getNodeParameter('triggerOn') as string; - const webhookData = this.getWorkflowStaticData('node') as IDataObject; + const webhookData = this.getWorkflowStaticData('node'); const webhookUrl = this.getNodeWebhookUrl('default') as string; if (webhookUrl.includes('//localhost')) { @@ -121,7 +121,7 @@ export class OnfleetTrigger implements INodeType { return true; }, async delete(this: IHookFunctions): Promise { - const webhookData = this.getWorkflowStaticData('node') as IDataObject; + const webhookData = this.getWorkflowStaticData('node'); // Get the data of the already registered webhook const endpoint = `/webhooks/${webhookData.id}`; await onfleetApiRequest.call(this, 'DELETE', endpoint); diff --git a/packages/nodes-base/nodes/Orbit/Orbit.node.ts b/packages/nodes-base/nodes/Orbit/Orbit.node.ts index 6c40dbeb05..f2b03d80ce 100644 --- a/packages/nodes-base/nodes/Orbit/Orbit.node.ts +++ b/packages/nodes-base/nodes/Orbit/Orbit.node.ts @@ -163,7 +163,7 @@ export class Orbit implements INodeType { if (filters.memberId) { endpoint = `/${workspaceId}/members/${filters.memberId}/activities`; } - if (returnAll === true) { + if (returnAll) { responseData = await orbitApiRequestAllItems.call( this, 'data', @@ -280,7 +280,7 @@ export class Orbit implements INodeType { 'GET', `/${workspaceId}/members/${memberId}`, ); - if (resolve === true) { + if (resolve) { resolveIdentities(responseData); } responseData = responseData.data; @@ -291,7 +291,7 @@ export class Orbit implements INodeType { const options = this.getNodeParameter('options', i); Object.assign(qs, options); qs.resolveIdentities = this.getNodeParameter('resolveIdentities', 0) as boolean; - if (returnAll === true) { + if (returnAll) { responseData = await orbitApiRequestAllItems.call( this, 'data', @@ -418,7 +418,7 @@ export class Orbit implements INodeType { const memberId = this.getNodeParameter('memberId', i) as string; const returnAll = this.getNodeParameter('returnAll', i); qs.resolveMember = this.getNodeParameter('resolveMember', 0) as boolean; - if (returnAll === true) { + if (returnAll) { responseData = await orbitApiRequestAllItems.call( this, 'data', @@ -488,7 +488,7 @@ export class Orbit implements INodeType { if (filters.memberId) { endpoint = `/${workspaceId}/members/${filters.memberId}/activities`; } - if (returnAll === true) { + if (returnAll) { responseData = await orbitApiRequestAllItems.call( this, 'data', diff --git a/packages/nodes-base/nodes/Oura/Oura.node.ts b/packages/nodes-base/nodes/Oura/Oura.node.ts index a68b50c2de..d3cb09e41e 100644 --- a/packages/nodes-base/nodes/Oura/Oura.node.ts +++ b/packages/nodes-base/nodes/Oura/Oura.node.ts @@ -111,7 +111,7 @@ export class Oura implements INodeType { responseData = await ouraApiRequest.call(this, 'GET', '/activity', {}, qs); responseData = responseData.activity; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.splice(0, limit); } @@ -123,7 +123,7 @@ export class Oura implements INodeType { responseData = await ouraApiRequest.call(this, 'GET', '/readiness', {}, qs); responseData = responseData.readiness; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.splice(0, limit); } @@ -135,7 +135,7 @@ export class Oura implements INodeType { responseData = await ouraApiRequest.call(this, 'GET', '/sleep', {}, qs); responseData = responseData.sleep; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.splice(0, limit); } diff --git a/packages/nodes-base/nodes/Paddle/GenericFunctions.ts b/packages/nodes-base/nodes/Paddle/GenericFunctions.ts index 67fdbc2ea2..0bf3a8390e 100644 --- a/packages/nodes-base/nodes/Paddle/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Paddle/GenericFunctions.ts @@ -40,8 +40,8 @@ export async function paddleApiRequest( json: true, }; - body['vendor_id'] = credentials.vendorId; - body['vendor_auth_code'] = credentials.vendorAuthCode; + body.vendor_id = credentials.vendorId; + body.vendor_auth_code = credentials.vendorAuthCode; try { const response = await this.helpers.request!(options); diff --git a/packages/nodes-base/nodes/Paddle/Paddle.node.ts b/packages/nodes-base/nodes/Paddle/Paddle.node.ts index 25acca4e10..db3611dc5f 100644 --- a/packages/nodes-base/nodes/Paddle/Paddle.node.ts +++ b/packages/nodes-base/nodes/Paddle/Paddle.node.ts @@ -223,9 +223,7 @@ export class Paddle implements INodeType { body.coupon_prefix = additionalFields.couponPrefix as string; } if (additionalFields.expires) { - body.expires = moment(additionalFields.expires as Date).format( - 'YYYY-MM-DD', - ) as string; + body.expires = moment(additionalFields.expires as Date).format('YYYY-MM-DD'); } if (additionalFields.group) { body.group = additionalFields.group as string; @@ -256,7 +254,7 @@ export class Paddle implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); const endpoint = '/2.0/product/list_coupons'; - body.product_id = productId as string; + body.product_id = productId; responseData = await paddleApiRequest.call(this, endpoint, 'POST', body); @@ -309,9 +307,7 @@ export class Paddle implements INodeType { body.new_coupon_code = additionalFields.newCouponCode as string; } if (additionalFields.expires) { - body.expires = moment(additionalFields.expires as Date).format( - 'YYYY-MM-DD', - ) as string; + body.expires = moment(additionalFields.expires as Date).format('YYYY-MM-DD'); } if (additionalFields.newGroup) { body.new_group = additionalFields.newGroup as string; @@ -389,10 +385,10 @@ export class Paddle implements INodeType { body.is_paid = 0; } if (additionalFields.from) { - body.from = moment(additionalFields.from as Date).format('YYYY-MM-DD') as string; + body.from = moment(additionalFields.from as Date).format('YYYY-MM-DD'); } if (additionalFields.to) { - body.to = moment(additionalFields.to as Date).format('YYYY-MM-DD') as string; + body.to = moment(additionalFields.to as Date).format('YYYY-MM-DD'); } if (additionalFields.isOneOffCharge) { body.is_one_off_charge = additionalFields.isOneOffCharge as boolean; @@ -414,7 +410,7 @@ export class Paddle implements INodeType { const date = this.getNodeParameter('date', i) as Date; body.payment_id = paymentId; - body.date = body.to = moment(date as Date).format('YYYY-MM-DD') as string; + body.date = body.to = moment(date).format('YYYY-MM-DD'); const endpoint = '/2.0/subscription/payments_reschedule'; diff --git a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts index 3dacbeb2bd..8391833133 100644 --- a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts @@ -45,11 +45,11 @@ export async function pagerDutyApiRequest( if (authenticationMethod === 'apiToken') { const credentials = await this.getCredentials('pagerDutyApi'); - options.headers!['Authorization'] = `Token token=${credentials.apiToken}`; + options.headers.Authorization = `Token token=${credentials.apiToken}`; - return await this.helpers.request!(options); + return this.helpers.request!(options); } else { - return await this.helpers.requestOAuth2!.call(this, 'pagerDutyOAuth2Api', options); + return this.helpers.requestOAuth2!.call(this, 'pagerDutyOAuth2Api', options); } } catch (error) { throw new NodeApiError(this.getNode(), error); diff --git a/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts b/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts index d66a375b97..aaaf3c9f27 100644 --- a/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts +++ b/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts @@ -278,12 +278,12 @@ export class PagerDuty implements INodeType { //https://api-reference.pagerduty.com/#!/Incidents/get_incidents if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0); - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); if (options.userIds) { - options.userIds = (options.userIds as string).split(',') as string[]; + options.userIds = (options.userIds as string).split(','); } if (options.teamIds) { - options.teamIds = (options.teamIds as string).split(',') as string[]; + options.teamIds = (options.teamIds as string).split(','); } if (options.include) { options.include = (options.include as string[]).map((e) => snakeCase(e)); diff --git a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts index 9a2077a993..8deb7b34d1 100644 --- a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts @@ -64,8 +64,8 @@ async function getAccessToken( | IWebhookFunctions, ): Promise { const credentials = await this.getCredentials('payPalApi'); - const env = getEnvironment(credentials!.env as string); - const data = Buffer.from(`${credentials!.clientId}:${credentials!.secret}`).toString( + const env = getEnvironment(credentials.env as string); + const data = Buffer.from(`${credentials.clientId}:${credentials.secret}`).toString( BINARY_ENCODING, ); const headerWithAuthentication = Object.assign( diff --git a/packages/nodes-base/nodes/PayPal/PayPal.node.ts b/packages/nodes-base/nodes/PayPal/PayPal.node.ts index b16009c3da..aaab6ee9db 100644 --- a/packages/nodes-base/nodes/PayPal/PayPal.node.ts +++ b/packages/nodes-base/nodes/PayPal/PayPal.node.ts @@ -191,7 +191,7 @@ export class PayPal implements INodeType { if (operation === 'get') { const payoutBatchId = this.getNodeParameter('payoutBatchId', i) as string; const returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === true) { + if (returnAll) { responseData = await payPalApiRequestAllItems.call( this, 'items', diff --git a/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts b/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts index 715e5d4fdc..53c558dd3e 100644 --- a/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts +++ b/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts @@ -156,8 +156,8 @@ export class PayPalTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { let webhook; - const webhookData = this.getWorkflowStaticData('node') as IDataObject; - const bodyData = this.getBodyData() as IDataObject; + const webhookData = this.getWorkflowStaticData('node'); + const bodyData = this.getBodyData(); const req = this.getRequestObject(); const headerData = this.getHeaderData() as IDataObject; const endpoint = '/notifications/verify-webhook-signature'; diff --git a/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts b/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts index ea3934a3b9..cb0a7cdde1 100644 --- a/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts +++ b/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts @@ -153,7 +153,7 @@ export class Phantombuster implements INodeType { qs, ); - if (resolveData === true) { + if (resolveData) { const { resultObject } = await phantombusterApiRequest.call( this, 'GET', @@ -175,7 +175,7 @@ export class Phantombuster implements INodeType { responseData = await phantombusterApiRequest.call(this, 'GET', '/agents/fetch-all'); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.splice(0, limit); } @@ -214,8 +214,8 @@ export class Phantombuster implements INodeType { } } else { const argumentParameters = - (((additionalFields.argumentsUi as IDataObject) || {}) - .argumentValues as IDataObject[]) || []; + ((additionalFields.argumentsUi as IDataObject)?.argumentValues as IDataObject[]) || + []; body.arguments = argumentParameters.reduce((object, currentValue) => { object[currentValue.key as string] = currentValue.value; return object; @@ -223,8 +223,8 @@ export class Phantombuster implements INodeType { delete additionalFields.argumentsUi; const bonusParameters = - (((additionalFields.bonusArgumentUi as IDataObject) || {}) - .bonusArgumentValue as IDataObject[]) || []; + ((additionalFields.bonusArgumentUi as IDataObject) + ?.bonusArgumentValue as IDataObject[]) || []; body.bonusArgument = bonusParameters.reduce((object, currentValue) => { object[currentValue.key as string] = currentValue.value; return object; @@ -236,7 +236,7 @@ export class Phantombuster implements INodeType { responseData = await phantombusterApiRequest.call(this, 'POST', '/agents/launch', body); - if (resolveData === true) { + if (resolveData) { responseData = await phantombusterApiRequest.call( this, 'GET', diff --git a/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts b/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts index f0e1722266..bc71f21ed9 100644 --- a/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts @@ -121,11 +121,7 @@ export async function pipedriveApiRequestAllItems( } query.start = responseData.additionalData.pagination.next_start; - } while ( - responseData.additionalData !== undefined && - responseData.additionalData.pagination !== undefined && - responseData.additionalData.pagination.more_items_in_collection === true - ); + } while (responseData.additionalData?.pagination?.more_items_in_collection === true); return { data: returnData, @@ -190,7 +186,7 @@ export function pipedriveEncodeCustomProperties( for (const key of Object.keys(item)) { customPropertyData = Object.values(customProperties).find( - (customPropertyData) => customPropertyData.name === key, + (propertyData) => propertyData.name === key, ); if (customPropertyData !== undefined) { @@ -209,12 +205,12 @@ export function pipedriveEncodeCustomProperties( ); if (propertyOption !== undefined) { - item[customPropertyData.key as string] = propertyOption.id; + item[customPropertyData.key] = propertyOption.id; delete item[key]; } } else { // Does already represent the actual value or is null - item[customPropertyData.key as string] = item[key]; + item[customPropertyData.key] = item[key]; delete item[key]; } } @@ -265,7 +261,7 @@ export function pipedriveResolveCustomProperties( 'timerange', ].includes(customPropertyData.field_type) ) { - json[customPropertyData.name as string] = json[key]; + json[customPropertyData.name] = json[key]; delete json[key]; // type options } else if ( @@ -276,7 +272,7 @@ export function pipedriveResolveCustomProperties( (option) => option.id.toString() === json[key]!.toString(), ); if (propertyOption !== undefined) { - json[customPropertyData.name as string] = propertyOption.label; + json[customPropertyData.name] = propertyOption.label; delete json[key]; } // type multioptions diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index 3ba1eae4ae..012d7fc0b2 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -3763,7 +3763,7 @@ export class Pipedrive implements INodeType { 'GET', '/filters', {}, - { type: type[resource] as string }, + { type: type[resource] }, ); for (const filter of data) { returnData.push({ @@ -4052,7 +4052,7 @@ export class Pipedrive implements INodeType { getCustomProperties = this.getNodeParameter('resolveProperties', 0, false) as boolean; } - if (getCustomProperties === true) { + if (getCustomProperties) { customProperties = await pipedriveGetCustomProperties.call(this, resource); } } @@ -4106,7 +4106,7 @@ export class Pipedrive implements INodeType { requestMethod = 'GET'; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4194,7 +4194,7 @@ export class Pipedrive implements INodeType { requestMethod = 'GET'; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } const filters = this.getNodeParameter('filters', i); @@ -4227,7 +4227,7 @@ export class Pipedrive implements INodeType { qs.term = this.getNodeParameter('term', i) as string; returnAll = this.getNodeParameter('returnAll', i); qs.exact_match = this.getNodeParameter('exactMatch', i) as boolean; - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4265,7 +4265,7 @@ export class Pipedrive implements INodeType { returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4275,7 +4275,7 @@ export class Pipedrive implements INodeType { qs.exclude = additionalFields.exclude as string; } - if (additionalFields && additionalFields.done !== undefined) { + if (additionalFields?.done !== undefined) { qs.done = additionalFields.done === true ? 1 : 0; } @@ -4437,7 +4437,7 @@ export class Pipedrive implements INodeType { endpoint = `/notes`; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } const additionalFields = this.getNodeParameter('additionalFields', i); @@ -4536,7 +4536,7 @@ export class Pipedrive implements INodeType { // https://developers.pipedrive.com/docs/api/v1/Leads#getLeads returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4627,7 +4627,7 @@ export class Pipedrive implements INodeType { requestMethod = 'GET'; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4668,7 +4668,7 @@ export class Pipedrive implements INodeType { qs.term = this.getNodeParameter('term', i) as string; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4724,7 +4724,7 @@ export class Pipedrive implements INodeType { requestMethod = 'GET'; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4748,7 +4748,7 @@ export class Pipedrive implements INodeType { qs.term = this.getNodeParameter('term', i) as string; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4797,7 +4797,7 @@ export class Pipedrive implements INodeType { requestMethod = 'GET'; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -4810,7 +4810,7 @@ export class Pipedrive implements INodeType { } let responseData; - if (returnAll === true) { + if (returnAll) { responseData = await pipedriveApiRequestAllItems.call( this, requestMethod, @@ -4820,7 +4820,7 @@ export class Pipedrive implements INodeType { ); } else { if (customProperties !== undefined) { - pipedriveEncodeCustomProperties(customProperties!, body); + pipedriveEncodeCustomProperties(customProperties, body); } responseData = await pipedriveApiRequest.call( diff --git a/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts b/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts index 8bed90aee6..7ec4509e76 100644 --- a/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts @@ -344,8 +344,8 @@ export class PipedriveTrigger implements INodeType { } if ( - basicAuthData.name !== httpBasicAuth!.user || - basicAuthData.pass !== httpBasicAuth!.password + basicAuthData.name !== httpBasicAuth.user || + basicAuthData.pass !== httpBasicAuth.password ) { // Provided authentication data is wrong return authorizationError(resp, realm, 403); diff --git a/packages/nodes-base/nodes/PostHog/PostHog.node.ts b/packages/nodes-base/nodes/PostHog/PostHog.node.ts index 5a74493c3d..4a7039dc76 100644 --- a/packages/nodes-base/nodes/PostHog/PostHog.node.ts +++ b/packages/nodes-base/nodes/PostHog/PostHog.node.ts @@ -90,8 +90,7 @@ export class PostHog implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); const context = - (((additionalFields.contextUi as IDataObject) || {}) - .contextValues as IDataObject[]) || []; + ((additionalFields.contextUi as IDataObject)?.contextValues as IDataObject[]) || []; const event: IAlias = { type: 'alias', @@ -140,8 +139,8 @@ export class PostHog implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); const properties = - (((additionalFields.propertiesUi as IDataObject) || {}) - .propertyValues as IDataObject[]) || []; + ((additionalFields.propertiesUi as IDataObject)?.propertyValues as IDataObject[]) || + []; const event: IEvent = { event: eventName, @@ -151,7 +150,7 @@ export class PostHog implements INodeType { ), }; - event.properties['distinct_id'] = distinctId; + event.properties.distinct_id = distinctId; Object.assign(event, additionalFields); @@ -188,8 +187,8 @@ export class PostHog implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); const properties = - (((additionalFields.propertiesUi as IDataObject) || {}) - .propertyValues as IDataObject[]) || []; + ((additionalFields.propertiesUi as IDataObject)?.propertyValues as IDataObject[]) || + []; const event: IIdentity = { event: '$identify', @@ -235,12 +234,11 @@ export class PostHog implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); const context = - (((additionalFields.contextUi as IDataObject) || {}) - .contextValues as IDataObject[]) || []; + ((additionalFields.contextUi as IDataObject)?.contextValues as IDataObject[]) || []; const properties = - (((additionalFields.propertiesUi as IDataObject) || {}) - .propertyValues as IDataObject[]) || []; + ((additionalFields.propertiesUi as IDataObject)?.propertyValues as IDataObject[]) || + []; const event: ITrack = { name, diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts index 1158b599f5..308defe5b7 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts @@ -80,6 +80,7 @@ export function generateReturning(pgp: pgPromise.IMain<{}, pg.IClient>, returnin * @param {input[]} input The Node's input data */ export async function pgQuery( + // eslint-disable-next-line @typescript-eslint/ban-types getNodeParam: Function, pgp: pgPromise.IMain<{}, pg.IClient>, db: pgPromise.IDatabase<{}, pg.IClient>, @@ -118,7 +119,7 @@ export async function pgQuery( await t.any(allQueries[i].query, allQueries[i].values), ); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ ...items[i].json, code: (err as JsonObject).code, @@ -139,7 +140,7 @@ export async function pgQuery( await t.any(allQueries[i].query, allQueries[i].values), ); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ ...items[i].json, code: (err as JsonObject).code, @@ -201,7 +202,7 @@ export async function pgQueryV2( ); result.push(...executionData); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ json: { ...items[i].json }, code: (err as JsonObject).code, @@ -225,7 +226,7 @@ export async function pgQueryV2( ); result.push(...executionData); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ json: { ...items[i].json }, code: (err as JsonObject).code, @@ -249,6 +250,7 @@ export async function pgQueryV2( * @param {INodeExecutionData[]} items The items to be inserted */ export async function pgInsert( + // eslint-disable-next-line @typescript-eslint/ban-types getNodeParam: Function, pgp: pgPromise.IMain<{}, pg.IClient>, db: pgPromise.IDatabase<{}, pg.IClient>, @@ -289,7 +291,7 @@ export async function pgInsert( try { result.push(await t.one(pgp.helpers.insert(itemCopy, cs) + returning)); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ ...itemCopy, code: (err as JsonObject).code, @@ -311,7 +313,7 @@ export async function pgInsert( result.push(insertResult); } } catch (err) { - if (continueOnFail === false) { + if (!continueOnFail) { throw err; } result.push({ @@ -389,7 +391,7 @@ export async function pgInsertV2( }), ); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ json: { ...itemCopy }, code: (err as JsonObject).code, @@ -416,7 +418,7 @@ export async function pgInsertV2( result.push(...executionData); } } catch (err) { - if (continueOnFail === false) { + if (!continueOnFail) { throw err; } result.push({ @@ -443,6 +445,7 @@ export async function pgInsertV2( * @param {INodeExecutionData[]} items The items to be updated */ export async function pgUpdate( + // eslint-disable-next-line @typescript-eslint/ban-types getNodeParam: Function, pgp: pgPromise.IMain<{}, pg.IClient>, db: pgPromise.IDatabase<{}, pg.IClient>, @@ -491,19 +494,17 @@ export async function pgUpdate( pgp.helpers.update(updateItems, cs) + ' WHERE ' + updateKeys - .map((updateKey) => { - const key = pgp.as.name(updateKey.name); + .map((entry) => { + const key = pgp.as.name(entry.name); return 'v.' + key + ' = t.' + key; }) .join(' AND ') + returning; - return await db.any(query); + return db.any(query); } else { const where = ' WHERE ' + - updateKeys - .map((updateKey) => pgp.as.name(updateKey.name) + ' = ${' + updateKey.prop + '}') - .join(' AND '); + updateKeys.map((entry) => pgp.as.name(entry.name) + ' = ${' + entry.prop + '}').join(' AND '); if (mode === 'transaction') { return db.tx(async (t) => { const result: IDataObject[] = []; @@ -517,7 +518,7 @@ export async function pgUpdate( ), ); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ ...itemCopy, code: (err as JsonObject).code, @@ -541,7 +542,7 @@ export async function pgUpdate( ), ); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ ...itemCopy, code: (err as JsonObject).code, @@ -613,8 +614,8 @@ export async function pgUpdateV2( pgp.helpers.update(updateItems, cs) + ' WHERE ' + updateKeys - .map((updateKey) => { - const key = pgp.as.name(updateKey.name); + .map((entry) => { + const key = pgp.as.name(entry.name); return 'v.' + key + ' = t.' + key; }) .join(' AND ') + @@ -624,9 +625,7 @@ export async function pgUpdateV2( } else { const where = ' WHERE ' + - updateKeys - .map((updateKey) => pgp.as.name(updateKey.name) + ' = ${' + updateKey.prop + '}') - .join(' AND '); + updateKeys.map((entry) => pgp.as.name(entry.name) + ' = ${' + entry.prop + '}').join(' AND '); if (mode === 'transaction') { return db.tx(async (t) => { const result: IDataObject[] = []; @@ -642,7 +641,7 @@ export async function pgUpdateV2( ); result.push(...executionData); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ ...itemCopy, code: (err as JsonObject).code, @@ -668,7 +667,7 @@ export async function pgUpdateV2( ); result.push(...executionData); } catch (err) { - if (continueOnFail === false) throw err; + if (!continueOnFail) throw err; result.push({ json: { ...items[i].json }, code: (err as JsonObject).code, diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.ts index 4df919a462..915fd0be5f 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.ts @@ -277,6 +277,7 @@ export class Postgres implements INodeType { }, ], }; + methods = { credentialTest: { async postgresConnectionTest( @@ -305,7 +306,7 @@ export class Postgres implements INodeType { const db = pgp(config); await db.connect(); - await pgp.end(); + pgp.end(); } catch (error) { return { status: 'Error', @@ -394,7 +395,7 @@ export class Postgres implements INodeType { returnItems = this.helpers.returnJsonArray(updateItems); } else { - await pgp.end(); + pgp.end(); throw new NodeOperationError( this.getNode(), `The operation "${operation}" is not supported!`, @@ -402,7 +403,7 @@ export class Postgres implements INodeType { } // Close the connection - await pgp.end(); + pgp.end(); return this.prepareOutputData(returnItems); } diff --git a/packages/nodes-base/nodes/Postmark/GenericFunctions.ts b/packages/nodes-base/nodes/Postmark/GenericFunctions.ts index fb041bf81a..e8012b06fe 100644 --- a/packages/nodes-base/nodes/Postmark/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Postmark/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function postmarkApiRequest( options = Object.assign({}, options, option); try { - return await this.helpers.requestWithAuthentication.call(this, 'postmarkApi', options); + return this.helpers.requestWithAuthentication.call(this, 'postmarkApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts index a81183092c..2361e6ae71 100644 --- a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts @@ -65,7 +65,7 @@ export function simplifyMontlyMetrics(responseData: { for (const key of Object.keys(responseData)) { for (const [index] of responseData[key].entries()) { data[key] = responseData[key][index].value; - data['date'] = responseData[key][index].date; + data.date = responseData[key][index].date; } } return data; diff --git a/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts b/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts index 375bc540c5..2a74855edd 100644 --- a/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts +++ b/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts @@ -123,7 +123,7 @@ export class ProfitWell implements INodeType { responseData = await profitWellApiRequest.call(this, 'GET', `/metrics/${type}`, {}, qs); responseData = responseData.data; - if (simple === true) { + if (simple) { if (type === 'daily') { responseData = simplifyDailyMetrics(responseData); } else { diff --git a/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts b/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts index 0afc714457..119805629d 100644 --- a/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts +++ b/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts @@ -395,7 +395,7 @@ export class Pushbullet implements INodeType { if (target !== 'default') { const value = this.getNodeParameter('value', i) as string; - body[target as string] = value; + body[target] = value; } if (['note', 'link'].includes(type)) { diff --git a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts index b29003d7e7..7ce44cf19e 100644 --- a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts @@ -34,7 +34,7 @@ export async function pushcutApiRequest( Object.assign(options, option); } //@ts-ignore - return await this.helpers.request.call(this, options); + return this.helpers.request.call(this, options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts b/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts index 65349a1ef3..2011eb776a 100644 --- a/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts +++ b/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts @@ -1,6 +1,6 @@ import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; +import { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; import { pushcutApiRequest } from './GenericFunctions'; @@ -108,7 +108,7 @@ export class PushcutTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const body = this.getBodyData() as IDataObject; + const body = this.getBodyData(); return { workflowData: [this.helpers.returnJsonArray(body)], diff --git a/packages/nodes-base/nodes/Pushover/Pushover.node.ts b/packages/nodes-base/nodes/Pushover/Pushover.node.ts index 3d1812be00..479c110210 100644 --- a/packages/nodes-base/nodes/Pushover/Pushover.node.ts +++ b/packages/nodes-base/nodes/Pushover/Pushover.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IBinaryKeyData, IDataObject, ILoadOptionsFunctions, @@ -349,7 +348,7 @@ export class Pushover implements INodeType { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryPropertyName] as IBinaryData; + const binaryData = item[binaryPropertyName]; if (binaryData === undefined) { throw new NodeOperationError( diff --git a/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts b/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts index 905c2223d0..849c9ad4b3 100644 --- a/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts +++ b/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts @@ -256,7 +256,7 @@ export class QuestDb implements INodeType { returnItems = this.helpers.returnJsonArray(insertData); } else { - await pgp.end(); + pgp.end(); throw new NodeOperationError( this.getNode(), `The operation "${operation}" is not supported!`, @@ -264,7 +264,7 @@ export class QuestDb implements INodeType { } // Close the connection - await pgp.end(); + pgp.end(); return this.prepareOutputData(returnItems); } diff --git a/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts index 14241386e8..e3434c2819 100644 --- a/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts @@ -114,11 +114,11 @@ export async function quickbaseApiRequestAllItems( } for (const record of data) { - const data: IDataObject = {}; + const recordData: IDataObject = {}; for (const [key, value] of Object.entries(record)) { - data[fieldsIdKey[key]] = (value as IDataObject).value; + recordData[fieldsIdKey[key]] = (value as IDataObject).value; } - responseData.push(data); + responseData.push(recordData); } if (method === 'POST') { diff --git a/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts b/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts index 68971c9e39..1cc466b7db 100644 --- a/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts +++ b/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts @@ -133,15 +133,16 @@ export class QuickBase implements INodeType { const options = this.getNodeParameter('options', i); - const qs: IDataObject = { - tableId, - }; - - Object.assign(qs, options); + Object.assign( + { + tableId, + }, + options, + ); responseData = await quickbaseApiRequest.call(this, 'GET', '/fields', {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); @@ -241,7 +242,7 @@ export class QuickBase implements INodeType { const data: IDataObject[] = []; - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); for (let i = 0; i < length; i++) { const record: IDataObject = {}; @@ -280,16 +281,16 @@ export class QuickBase implements INodeType { responseData = await quickbaseApiRequest.call(this, 'POST', '/records', body); - if (simple === true) { + if (simple) { const { data: records } = responseData; responseData = []; for (const record of records) { - const data: IDataObject = {}; + const recordData: IDataObject = {}; for (const [key, value] of Object.entries(record)) { - data[key] = (value as IDataObject).value; + recordData[key] = (value as IDataObject).value; } - responseData.push(data); + responseData.push(recordData); } } @@ -402,7 +403,7 @@ export class QuickBase implements INodeType { const data: IDataObject[] = []; - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); for (let i = 0; i < length; i++) { const record: IDataObject = {}; @@ -450,16 +451,16 @@ export class QuickBase implements INodeType { responseData = await quickbaseApiRequest.call(this, 'POST', '/records', body); - if (simple === true) { + if (simple) { const { data: records } = responseData; responseData = []; for (const record of records) { - const data: IDataObject = {}; + const recordData: IDataObject = {}; for (const [key, value] of Object.entries(record)) { - data[fieldsIdKey[key]] = (value as IDataObject).value; + recordData[fieldsIdKey[key]] = (value as IDataObject).value; } - responseData.push(data); + responseData.push(recordData); } } @@ -482,7 +483,7 @@ export class QuickBase implements INodeType { const data: IDataObject[] = []; - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); for (let i = 0; i < length; i++) { const record: IDataObject = {}; @@ -533,16 +534,16 @@ export class QuickBase implements INodeType { responseData = await quickbaseApiRequest.call(this, 'POST', '/records', body); - if (simple === true) { + if (simple) { const { data: records } = responseData; responseData = []; for (const record of records) { - const data: IDataObject = {}; + const recordData: IDataObject = {}; for (const [key, value] of Object.entries(record)) { - data[key] = (value as IDataObject).value; + recordData[key] = (value as IDataObject).value; } - responseData.push(data); + responseData.push(recordData); } } diff --git a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts index dc96de00ba..94ffa5a0c2 100644 --- a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts @@ -69,7 +69,7 @@ export async function quickBooksApiRequest( } if (isDownload) { - options.headers!['Accept'] = 'application/pdf'; + options.headers!.Accept = 'application/pdf'; } if (resource === 'invoice' && operation === 'send') { @@ -84,7 +84,7 @@ export async function quickBooksApiRequest( } try { - return await this.helpers.requestOAuth2!.call(this, 'quickBooksOAuth2Api', options); + return this.helpers.requestOAuth2!.call(this, 'quickBooksOAuth2Api', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -168,7 +168,7 @@ export async function handleListing( } if (returnAll) { - return await quickBooksApiRequestAllItems.call(this, 'GET', endpoint, qs, {}, resource); + return quickBooksApiRequestAllItems.call(this, 'GET', endpoint, qs, {}, resource); } else { const limit = this.getNodeParameter('limit', i); qs.query += ` MAXRESULTS ${limit}`; @@ -268,6 +268,7 @@ export async function loadResource(this: ILoadOptionsFunctions, resource: string if (resource === 'preferences') { const { + // eslint-disable-next-line @typescript-eslint/no-shadow SalesFormsPrefs: { CustomField }, } = resourceItems[0]; const customFields = CustomField[1].CustomField; @@ -398,7 +399,7 @@ export function populateFields( const length = (body.CustomField as CustomField[]).length; for (let i = 0; i < length; i++) { //@ts-ignore - body.CustomField[i]['Type'] = 'StringType'; + body.CustomField[i].Type = 'StringType'; } } else if (key === 'CustomerMemo') { body.CustomerMemo = { diff --git a/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts b/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts index 4248823a99..aac3289a3b 100644 --- a/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts +++ b/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts @@ -148,39 +148,39 @@ export class QuickBooks implements INodeType { methods = { loadOptions: { async getCustomers(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'customer'); + return loadResource.call(this, 'customer'); }, async getCustomFields(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'preferences'); + return loadResource.call(this, 'preferences'); }, async getDepartments(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'department'); + return loadResource.call(this, 'department'); }, async getItems(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'item'); + return loadResource.call(this, 'item'); }, async getMemos(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'CreditMemo'); + return loadResource.call(this, 'CreditMemo'); }, async getPurchases(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'purchase'); + return loadResource.call(this, 'purchase'); }, async getTaxCodeRefs(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'TaxCode'); + return loadResource.call(this, 'TaxCode'); }, async getTerms(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'Term'); + return loadResource.call(this, 'Term'); }, async getVendors(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'vendor'); + return loadResource.call(this, 'vendor'); }, }, }; diff --git a/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts b/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts index 14a2a77d02..b861f77c31 100644 --- a/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts +++ b/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts @@ -101,6 +101,7 @@ export async function rabbitmqConnectExchange( export class MessageTracker { messages: number[] = []; + isClosing = false; received(message: amqplib.ConsumeMessage) { diff --git a/packages/nodes-base/nodes/RabbitMQ/RabbitMQ.node.ts b/packages/nodes-base/nodes/RabbitMQ/RabbitMQ.node.ts index f46030bdaf..a7e5371ddd 100644 --- a/packages/nodes-base/nodes/RabbitMQ/RabbitMQ.node.ts +++ b/packages/nodes-base/nodes/RabbitMQ/RabbitMQ.node.ts @@ -335,7 +335,7 @@ export class RabbitMQ implements INodeType { if (mode === 'queue') { const queue = this.getNodeParameter('queue', 0) as string; - options = this.getNodeParameter('options', 0, {}) as IDataObject; + options = this.getNodeParameter('options', 0, {}); channel = await rabbitmqConnectQueue.call(this, queue, options); @@ -345,7 +345,7 @@ export class RabbitMQ implements INodeType { const queuePromises = []; for (let i = 0; i < items.length; i++) { - if (sendInputData === true) { + if (sendInputData) { message = JSON.stringify(items[i].json); } else { message = this.getNodeParameter('message', i) as string; @@ -356,7 +356,7 @@ export class RabbitMQ implements INodeType { options.headers && ((options.headers as IDataObject).header! as IDataObject[]).length ) { - const itemOptions = this.getNodeParameter('options', i, {}) as IDataObject; + const itemOptions = this.getNodeParameter('options', i, {}); const additionalHeaders: IDataObject = {}; ((itemOptions.headers as IDataObject).header as IDataObject[]).forEach( (header: IDataObject) => { @@ -374,8 +374,8 @@ export class RabbitMQ implements INodeType { // @ts-ignore promisesResponses.forEach((response: JsonObject) => { - if (response!.status !== 'fulfilled') { - if (this.continueOnFail() !== true) { + if (response.status !== 'fulfilled') { + if (!this.continueOnFail()) { throw new NodeApiError(this.getNode(), response); } else { // Return the actual reason as error @@ -402,7 +402,7 @@ export class RabbitMQ implements INodeType { const type = this.getNodeParameter('exchangeType', 0) as string; const routingKey = this.getNodeParameter('routingKey', 0) as string; - options = this.getNodeParameter('options', 0, {}) as IDataObject; + options = this.getNodeParameter('options', 0, {}); channel = await rabbitmqConnectExchange.call(this, exchange, type, options); @@ -412,7 +412,7 @@ export class RabbitMQ implements INodeType { const exchangePromises = []; for (let i = 0; i < items.length; i++) { - if (sendInputData === true) { + if (sendInputData) { message = JSON.stringify(items[i].json); } else { message = this.getNodeParameter('message', i) as string; @@ -423,7 +423,7 @@ export class RabbitMQ implements INodeType { options.headers && ((options.headers as IDataObject).header! as IDataObject[]).length ) { - const itemOptions = this.getNodeParameter('options', i, {}) as IDataObject; + const itemOptions = this.getNodeParameter('options', i, {}); const additionalHeaders: IDataObject = {}; ((itemOptions.headers as IDataObject).header as IDataObject[]).forEach( (header: IDataObject) => { @@ -443,8 +443,8 @@ export class RabbitMQ implements INodeType { // @ts-ignore promisesResponses.forEach((response: JsonObject) => { - if (response!.status !== 'fulfilled') { - if (this.continueOnFail() !== true) { + if (response.status !== 'fulfilled') { + if (!this.continueOnFail()) { throw new NodeApiError(this.getNode(), response); } else { // Return the actual reason as error @@ -470,7 +470,7 @@ export class RabbitMQ implements INodeType { throw new NodeOperationError(this.getNode(), `The operation "${mode}" is not known!`); } - return this.prepareOutputData(returnItems); + return await this.prepareOutputData(returnItems); } catch (error) { if (channel) { await channel.close(); diff --git a/packages/nodes-base/nodes/RabbitMQ/RabbitMQTrigger.node.ts b/packages/nodes-base/nodes/RabbitMQ/RabbitMQTrigger.node.ts index 44e52f3ab7..7f36dea037 100644 --- a/packages/nodes-base/nodes/RabbitMQ/RabbitMQTrigger.node.ts +++ b/packages/nodes-base/nodes/RabbitMQ/RabbitMQTrigger.node.ts @@ -183,7 +183,7 @@ export class RabbitMQTrigger implements INodeType { const startConsumer = async () => { if (parallelMessages !== -1) { - channel.prefetch(parallelMessages); + await channel.prefetch(parallelMessages); } channel.on('close', () => { @@ -199,7 +199,7 @@ export class RabbitMQTrigger implements INodeType { messageTracker.received(message); } - let content: IDataObject | string = message!.content!.toString(); + let content: IDataObject | string = message.content.toString(); const item: INodeExecutionData = { json: {}, @@ -214,7 +214,7 @@ export class RabbitMQTrigger implements INodeType { message.content = undefined as unknown as Buffer; } else { if (options.jsonParseBody === true) { - content = JSON.parse(content as string); + content = JSON.parse(content); } if (options.onlyContent === true) { item.json = content as IDataObject; @@ -270,14 +270,14 @@ export class RabbitMQTrigger implements INodeType { consumerTag = consumerInfo.consumerTag; }; - startConsumer(); + await startConsumer(); // The "closeFunction" function gets called by n8n whenever // the workflow gets deactivated and can so clean up. async function closeFunction() { closeGotCalled = true; try { - return messageTracker.closeChannel(channel, consumerTag); + return await messageTracker.closeChannel(channel, consumerTag); } catch (error) { const workflow = self.getWorkflow(); const node = self.getNode(); diff --git a/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts b/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts index 0bf769b4be..bea2157e38 100644 --- a/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts @@ -40,7 +40,7 @@ export async function raindropApiRequest( } try { - return await this.helpers.requestOAuth2!.call(this, 'raindropOAuth2Api', options, { + return this.helpers.requestOAuth2!.call(this, 'raindropOAuth2Api', options, { includeCredentialsOnRefreshOnBody: true, }); } catch (error) { diff --git a/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts b/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts index f46bad454f..843804231a 100644 --- a/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts +++ b/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IDataObject, ILoadOptionsFunctions, INodeExecutionData, @@ -136,9 +135,7 @@ export class Raindrop implements INodeType { } if (additionalFields.tags) { - body.tags = (additionalFields.tags as string) - .split(',') - .map((tag) => tag.trim()) as string[]; + body.tags = (additionalFields.tags as string).split(',').map((tag) => tag.trim()); } const endpoint = `/raindrop`; @@ -172,7 +169,7 @@ export class Raindrop implements INodeType { responseData = await raindropApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.items; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.slice(0, limit); } @@ -208,9 +205,7 @@ export class Raindrop implements INodeType { delete updateFields.pleaseParse; } if (updateFields.tags) { - body.tags = (updateFields.tags as string) - .split(',') - .map((tag) => tag.trim()) as string[]; + body.tags = (updateFields.tags as string).split(',').map((tag) => tag.trim()); } const endpoint = `/raindrop/${bookmarkId}`; @@ -244,7 +239,7 @@ export class Raindrop implements INodeType { } if (additionalFields.parentId) { - body['parent.$id'] = parseInt(additionalFields.parentId as string, 10) as number; + body['parent.$id'] = parseInt(additionalFields.parentId as string, 10); delete additionalFields.parentId; } @@ -282,7 +277,7 @@ export class Raindrop implements INodeType { responseData = await raindropApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.items; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.slice(0, limit); } @@ -306,7 +301,7 @@ export class Raindrop implements INodeType { } if (updateFields.parentId) { - body['parent.$id'] = parseInt(updateFields.parentId as string, 10) as number; + body['parent.$id'] = parseInt(updateFields.parentId as string, 10); delete updateFields.parentId; } @@ -335,7 +330,7 @@ export class Raindrop implements INodeType { const binaryPropertyName = updateFields.cover as string; - const binaryData = items[i].binary![binaryPropertyName] as IBinaryData; + const binaryData = items[i].binary![binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); const formData = { @@ -348,11 +343,11 @@ export class Raindrop implements INodeType { }, }; - const endpoint = `/collection/${collectionId}/cover`; + const requestEndpoint = `/collection/${collectionId}/cover`; responseData = await raindropApiRequest.call( this, 'PUT', - endpoint, + requestEndpoint, {}, {}, { 'Content-Type': 'multipart/form-data', formData }, @@ -398,7 +393,7 @@ export class Raindrop implements INodeType { let endpoint = `/tags`; const body: IDataObject = { - tags: (this.getNodeParameter('tags', i) as string).split(',') as string[], + tags: (this.getNodeParameter('tags', i) as string).split(','), }; const additionalFields = this.getNodeParameter('additionalFields', i); @@ -426,7 +421,7 @@ export class Raindrop implements INodeType { responseData = await raindropApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.items; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.slice(0, limit); } diff --git a/packages/nodes-base/nodes/ReadBinaryFile/ReadBinaryFile.node.ts b/packages/nodes-base/nodes/ReadBinaryFile/ReadBinaryFile.node.ts index f7ad862299..22f7b45bb7 100644 --- a/packages/nodes-base/nodes/ReadBinaryFile/ReadBinaryFile.node.ts +++ b/packages/nodes-base/nodes/ReadBinaryFile/ReadBinaryFile.node.ts @@ -58,7 +58,7 @@ export class ReadBinaryFile implements INodeType { let data; try { - data = (await fsReadFile(filePath)) as Buffer; + data = await fsReadFile(filePath); } catch (error) { if (error.code === 'ENOENT') { throw new NodeOperationError( diff --git a/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts b/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts index 4c9ec040e3..718440bee3 100644 --- a/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts +++ b/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts @@ -49,7 +49,7 @@ export class ReadBinaryFiles implements INodeType { let item: INodeExecutionData; let data: Buffer; for (const filePath of files) { - data = (await fsReadFile(filePath)) as Buffer; + data = await fsReadFile(filePath); item = { binary: { diff --git a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts index 9bae3c14f4..9561001a06 100644 --- a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts @@ -81,10 +81,10 @@ export async function redditApiRequestAllItems( } else { responseData.data.children.forEach((child: any) => returnData.push(child.data)); } - if (qs.limit && returnData.length >= qs.limit && returnAll === false) { + if (qs.limit && returnData.length >= qs.limit && !returnAll) { return returnData; } - } while (responseData.data && responseData.data.after); + } while (responseData.data?.after); return returnData; } diff --git a/packages/nodes-base/nodes/Reddit/Reddit.node.ts b/packages/nodes-base/nodes/Reddit/Reddit.node.ts index 75ade5a8a5..f6b149c28b 100644 --- a/packages/nodes-base/nodes/Reddit/Reddit.node.ts +++ b/packages/nodes-base/nodes/Reddit/Reddit.node.ts @@ -372,7 +372,7 @@ export class Reddit implements INodeType { const endpoint = 'api/trending_subreddits.json'; responseData = await redditApiRequest.call(this, 'GET', endpoint, {}); responseData = responseData.subreddit_names.map((name: string) => ({ name })); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.splice(0, limit); } @@ -385,7 +385,7 @@ export class Reddit implements INodeType { const returnAll = this.getNodeParameter('returnAll', 0); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.subreddits.splice(0, limit); } diff --git a/packages/nodes-base/nodes/Redis/Redis.node.ts b/packages/nodes-base/nodes/Redis/Redis.node.ts index 6c259e378f..c81bd29e9f 100644 --- a/packages/nodes-base/nodes/Redis/Redis.node.ts +++ b/packages/nodes-base/nodes/Redis/Redis.node.ts @@ -511,7 +511,8 @@ export class Redis implements INodeType { redisOptions.password = credentials.password as string; } try { - const client = await redis.createClient(redisOptions); + const client = redis.createClient(redisOptions); + // tslint:disable-next-line: no-any const _data = await new Promise((resolve, reject): any => { client.on('connect', async () => { @@ -540,7 +541,7 @@ export class Redis implements INodeType { }, }; - execute(this: IExecuteFunctions): Promise { + async execute(this: IExecuteFunctions): Promise { // Parses the given value in a number if it is one else returns a string function getParsedValue(value: string): string | number { if (value.match(/^[\d\.]+$/) === null) { @@ -591,16 +592,16 @@ export class Redis implements INodeType { if (type === 'string') { const clientGet = util.promisify(client.get).bind(client); - return await clientGet(keyName); + return clientGet(keyName); } else if (type === 'hash') { const clientHGetAll = util.promisify(client.hgetall).bind(client); - return await clientHGetAll(keyName); + return clientHGetAll(keyName); } else if (type === 'list') { const clientLRange = util.promisify(client.lrange).bind(client); - return await clientLRange(keyName, 0, -1); + return clientLRange(keyName, 0, -1); } else if (type === 'sets') { const clientSMembers = util.promisify(client.smembers).bind(client); - return await clientSMembers(keyName); + return clientSMembers(keyName); } } @@ -644,7 +645,7 @@ export class Redis implements INodeType { } } - if (expire === true) { + if (expire) { const clientExpire = util.promisify(client.expire).bind(client); await clientExpire(keyName, ttl); } @@ -684,9 +685,7 @@ export class Redis implements INodeType { const clientInfo = util.promisify(client.info).bind(client); const result = await clientInfo(); - resolve( - this.prepareOutputData([{ json: convertInfoToObject(result as unknown as string) }]), - ); + resolve(this.prepareOutputData([{ json: convertInfoToObject(result as string) }])); client.quit(); } else if ( ['delete', 'get', 'keys', 'set', 'incr', 'publish', 'push', 'pop'].includes(operation) @@ -712,7 +711,7 @@ export class Redis implements INodeType { const value = (await getValue(client, keyGet, keyType)) || null; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); if (options.dotNotation === false) { item.json[propertyName] = value; @@ -742,6 +741,7 @@ export class Redis implements INodeType { } for (const keyName of keys) { + // eslint-disable-next-line @typescript-eslint/await-thenable item.json[keyName] = await promises[keyName]; } returnItems.push(item); @@ -761,7 +761,7 @@ export class Redis implements INodeType { const clientIncr = util.promisify(client.incr).bind(client); // @ts-ignore const incrementVal = await clientIncr(keyIncr); - if (expire === true && ttl > 0) { + if (expire && ttl > 0) { const clientExpire = util.promisify(client.expire).bind(client); await clientExpire(keyIncr, ttl); } @@ -800,7 +800,7 @@ export class Redis implements INodeType { } catch { outputValue = value; } - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); if (options.dotNotation === false) { item.json[propertyName] = outputValue; } else { diff --git a/packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts b/packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts index e8ed50d60b..ce227578fa 100644 --- a/packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts +++ b/packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts @@ -158,6 +158,52 @@ export class RenameKeys implements INodeType { let renameKeys: IRenameKey[]; let value: any; + const renameKey = (key: IRenameKey) => { + if (key.currentKey === '' || key.newKey === '' || key.currentKey === key.newKey) { + // Ignore all which do not have all the values set or if the new key is equal to the current key + return; + } + value = get(item.json, key.currentKey); + if (value === undefined) { + return; + } + set(newItem.json, key.newKey, value); + + unset(newItem.json, key.currentKey); + }; + + const regexReplaceKey = (replacement: IDataObject) => { + const { searchRegex, replaceRegex, options } = replacement; + const { depth, caseInsensitive } = options as IDataObject; + + const flags = (caseInsensitive as boolean) ? 'i' : undefined; + + const regex = new RegExp(searchRegex as string, flags); + + const renameObjectKeys = (obj: IDataObject, objDepth: number) => { + for (const key in obj) { + if (Array.isArray(obj)) { + // Don't rename array object references + if (objDepth !== 0) { + renameObjectKeys(obj[key] as IDataObject, objDepth - 1); + } + } else if (obj.hasOwnProperty(key)) { + if (typeof obj[key] === 'object' && objDepth !== 0) { + renameObjectKeys(obj[key] as IDataObject, objDepth - 1); + } + if (key.match(regex)) { + const newKey = key.replace(regex, replaceRegex as string); + if (newKey !== key) { + obj[newKey] = obj[key]; + delete obj[key]; + } + } + } + } + return obj; + }; + newItem.json = renameObjectKeys(newItem.json, depth as number); + }; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { renameKeys = this.getNodeParameter('keys.key', itemIndex, []) as IRenameKey[]; const regexReplacements = this.getNodeParameter( @@ -182,56 +228,9 @@ export class RenameKeys implements INodeType { newItem.binary = item.binary; } - renameKeys.forEach((renameKey) => { - if ( - renameKey.currentKey === '' || - renameKey.newKey === '' || - renameKey.currentKey === renameKey.newKey - ) { - // Ignore all which do not have all the values set or if the new key is equal to the current key - return; - } - value = get(item.json, renameKey.currentKey as string); - if (value === undefined) { - return; - } - set(newItem.json, renameKey.newKey, value); + renameKeys.forEach(renameKey); - unset(newItem.json, renameKey.currentKey as string); - }); - - regexReplacements.forEach((replacement) => { - const { searchRegex, replaceRegex, options } = replacement; - const { depth, caseInsensitive } = options as IDataObject; - - const flags = (caseInsensitive as boolean) ? 'i' : undefined; - - const regex = new RegExp(searchRegex as string, flags); - - const renameObjectKeys = (obj: IDataObject, depth: number) => { - for (const key in obj) { - if (Array.isArray(obj)) { - // Don't rename array object references - if (depth !== 0) { - renameObjectKeys(obj[key] as IDataObject, depth - 1); - } - } else if (obj.hasOwnProperty(key)) { - if (typeof obj[key] === 'object' && depth !== 0) { - renameObjectKeys(obj[key] as IDataObject, depth - 1); - } - if (key.match(regex)) { - const newKey = key.replace(regex, replaceRegex as string); - if (newKey !== key) { - obj[newKey] = obj[key]; - delete obj[key]; - } - } - } - } - return obj; - }; - newItem.json = renameObjectKeys(newItem.json, depth as number); - }); + regexReplacements.forEach(regexReplaceKey); returnData.push(newItem); } diff --git a/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts b/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts index e7a75158c8..e754232f9b 100644 --- a/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts +++ b/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts @@ -191,7 +191,7 @@ export class RespondToWebhook implements INodeType { const items = this.getInputData(); const respondWith = this.getNodeParameter('respondWith', 0) as string; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const headers = {} as IDataObject; if (options.responseHeaders) { diff --git a/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts b/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts index 55fd69af4a..0f37d105d2 100644 --- a/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts +++ b/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts @@ -399,53 +399,53 @@ export class Rocketchat implements INodeType { const optionsAttachments = this.getNodeParameter('attachments', i) as IDataObject[]; if (optionsAttachments.length > 0) { const attachments: IAttachment[] = []; - for (let i = 0; i < optionsAttachments.length; i++) { + for (let index = 0; index < optionsAttachments.length; index++) { const attachment: IAttachment = {}; - for (const option of Object.keys(optionsAttachments[i])) { + for (const option of Object.keys(optionsAttachments[index])) { if (option === 'color') { - attachment.color = optionsAttachments[i][option] as string; + attachment.color = optionsAttachments[index][option] as string; } else if (option === 'text') { - attachment.text = optionsAttachments[i][option] as string; + attachment.text = optionsAttachments[index][option] as string; } else if (option === 'ts') { - attachment.ts = optionsAttachments[i][option] as string; + attachment.ts = optionsAttachments[index][option] as string; } else if (option === 'messageLinks') { - attachment.message_link = optionsAttachments[i][option] as string; + attachment.message_link = optionsAttachments[index][option] as string; } else if (option === 'thumbUrl') { - attachment.thumb_url = optionsAttachments[i][option] as string; + attachment.thumb_url = optionsAttachments[index][option] as string; } else if (option === 'collapsed') { - attachment.collapsed = optionsAttachments[i][option] as boolean; + attachment.collapsed = optionsAttachments[index][option] as boolean; } else if (option === 'authorName') { - attachment.author_name = optionsAttachments[i][option] as string; + attachment.author_name = optionsAttachments[index][option] as string; } else if (option === 'authorLink') { - attachment.author_link = optionsAttachments[i][option] as string; + attachment.author_link = optionsAttachments[index][option] as string; } else if (option === 'authorIcon') { - attachment.author_icon = optionsAttachments[i][option] as string; + attachment.author_icon = optionsAttachments[index][option] as string; } else if (option === 'title') { - attachment.title = optionsAttachments[i][option] as string; + attachment.title = optionsAttachments[index][option] as string; } else if (option === 'titleLink') { - attachment.title_link = optionsAttachments[i][option] as string; + attachment.title_link = optionsAttachments[index][option] as string; } else if (option === 'titleLinkDownload') { - attachment.title_link_download = optionsAttachments[i][option] as boolean; + attachment.title_link_download = optionsAttachments[index][option] as boolean; } else if (option === 'imageUrl') { - attachment.image_url = optionsAttachments[i][option] as string; + attachment.image_url = optionsAttachments[index][option] as string; } else if (option === 'audioUrl') { - attachment.audio_url = optionsAttachments[i][option] as string; + attachment.audio_url = optionsAttachments[index][option] as string; } else if (option === 'videoUrl') { - attachment.video_url = optionsAttachments[i][option] as string; + attachment.video_url = optionsAttachments[index][option] as string; } else if (option === 'fields') { - const fieldsValues = (optionsAttachments[i][option] as IDataObject) + const fieldsValues = (optionsAttachments[index][option] as IDataObject) .fieldsValues as IDataObject[]; if (fieldsValues.length > 0) { const fields: IField[] = []; - for (let i = 0; i < fieldsValues.length; i++) { + for (let j = 0; j < fieldsValues.length; j++) { const field: IField = {}; - for (const key of Object.keys(fieldsValues[i])) { + for (const key of Object.keys(fieldsValues[j])) { if (key === 'short') { - field.short = fieldsValues[i][key] as boolean; + field.short = fieldsValues[j][key] as boolean; } else if (key === 'title') { - field.title = fieldsValues[i][key] as string; + field.title = fieldsValues[j][key] as string; } else if (key === 'value') { - field.value = fieldsValues[i][key] as string; + field.value = fieldsValues[j][key] as string; } } fields.push(field); diff --git a/packages/nodes-base/nodes/Rundeck/RundeckApi.ts b/packages/nodes-base/nodes/Rundeck/RundeckApi.ts index 59a47bd8f3..2e8c8856a8 100644 --- a/packages/nodes-base/nodes/Rundeck/RundeckApi.ts +++ b/packages/nodes-base/nodes/Rundeck/RundeckApi.ts @@ -9,6 +9,7 @@ export interface RundeckCredentials { export class RundeckApi { private credentials?: RundeckCredentials; + private executeFunctions: IExecuteFunctions; constructor(executeFunctions: IExecuteFunctions) { @@ -48,7 +49,7 @@ export class RundeckApi { this.credentials = credentials as unknown as RundeckCredentials; } - executeJob(jobId: string, args: IDataObject[]): Promise { + async executeJob(jobId: string, args: IDataObject[]): Promise { let params = ''; if (args) { @@ -64,7 +65,7 @@ export class RundeckApi { return this.request('POST', `/api/14/job/${jobId}/run`, body, {}); } - getJobMetadata(jobId: string): Promise { + async getJobMetadata(jobId: string): Promise { return this.request('GET', `/api/18/job/${jobId}/info`, {}, {}); } } diff --git a/packages/nodes-base/nodes/S3/GenericFunctions.ts b/packages/nodes-base/nodes/S3/GenericFunctions.ts index 21f105d160..9f9f28f465 100644 --- a/packages/nodes-base/nodes/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/S3/GenericFunctions.ts @@ -28,9 +28,7 @@ export async function s3ApiRequest( option: IDataObject = {}, region?: string, ): Promise { - let credentials; - - credentials = await this.getCredentials('s3'); + const credentials = await this.getCredentials('s3'); if (!(credentials.endpoint as string).startsWith('http')) { throw new NodeOperationError( diff --git a/packages/nodes-base/nodes/S3/S3.node.ts b/packages/nodes-base/nodes/S3/S3.node.ts index db7fdfb26d..a041d0e757 100644 --- a/packages/nodes-base/nodes/S3/S3.node.ts +++ b/packages/nodes-base/nodes/S3/S3.node.ts @@ -124,7 +124,7 @@ export class S3 implements INodeType { if (additionalFields.grantWriteAcp) { headers['x-amz-grant-write-acp'] = ''; } - let region = credentials!.region as string; + let region = credentials.region as string; if (additionalFields.region) { region = additionalFields.region as string; @@ -196,7 +196,7 @@ export class S3 implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', 0); if (additionalFields.prefix) { - qs['prefix'] = additionalFields.prefix as string; + qs.prefix = additionalFields.prefix as string; } if (additionalFields.encodingType) { @@ -204,7 +204,7 @@ export class S3 implements INodeType { } if (additionalFields.delmiter) { - qs['delimiter'] = additionalFields.delmiter as string; + qs.delimiter = additionalFields.delmiter as string; } if (additionalFields.fetchOwner) { @@ -400,10 +400,10 @@ export class S3 implements INodeType { if (operation === 'getAll') { const bucketName = this.getNodeParameter('bucketName', i) as string; const returnAll = this.getNodeParameter('returnAll', 0); - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); if (options.folderKey) { - qs['prefix'] = options.folderKey as string; + qs.prefix = options.folderKey as string; } if (options.fetchOwner) { @@ -680,17 +680,17 @@ export class S3 implements INodeType { if (operation === 'getAll') { const bucketName = this.getNodeParameter('bucketName', i) as string; const returnAll = this.getNodeParameter('returnAll', 0); - const options = this.getNodeParameter('options', 0) as IDataObject; + const options = this.getNodeParameter('options', 0); if (options.folderKey) { - qs['prefix'] = options.folderKey as string; + qs.prefix = options.folderKey as string; } if (options.fetchOwner) { qs['fetch-owner'] = options.fetchOwner as string; } - qs['delimiter'] = '/'; + qs.delimiter = '/'; qs['list-type'] = 2; @@ -748,7 +748,7 @@ export class S3 implements INodeType { if (operation === 'upload') { const bucketName = this.getNodeParameter('bucketName', i) as string; const fileName = this.getNodeParameter('fileName', i) as string; - const isBinaryData = this.getNodeParameter('binaryData', i) as boolean; + const isBinaryData = this.getNodeParameter('binaryData', i); const additionalFields = this.getNodeParameter('additionalFields', i); const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject) .tagsValues as IDataObject[]; diff --git a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts index f9191d52f8..3d540e4e06 100644 --- a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts @@ -2,14 +2,17 @@ import { OptionsWithUri } from 'request'; import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { IDataObject, INodePropertyOptions, NodeApiError } from 'n8n-workflow'; +import { + IDataObject, + INodePropertyOptions, + LoggerProxy as Logger, + NodeApiError, +} from 'n8n-workflow'; import moment from 'moment-timezone'; import jwt from 'jsonwebtoken'; -import { LoggerProxy as Logger } from 'n8n-workflow'; - export async function salesforceApiRequest( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, @@ -136,7 +139,7 @@ function getOptions( return options; } -function getAccessToken( +async function getAccessToken( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IDataObject, ): Promise { @@ -175,12 +178,11 @@ function getAccessToken( json: true, }; - //@ts-ignore - return this.helpers.request(options); + return this.helpers.request!(options); } export function getConditions(options: IDataObject) { - const conditions = ((options.conditionsUi as IDataObject) || {}).conditionValues as IDataObject[]; + const conditions = (options.conditionsUi as IDataObject)?.conditionValues as IDataObject[]; let data = undefined; if (Array.isArray(conditions) && conditions.length !== 0) { data = conditions.map( @@ -225,7 +227,7 @@ export function getQuery(options: IDataObject, sobject: string, returnAll: boole let query = `SELECT ${fields.join(',')} FROM ${sobject} ${conditions ? conditions : ''}`; - if (returnAll === false) { + if (!returnAll) { query = `SELECT ${fields.join(',')} FROM ${sobject} ${ conditions ? conditions : '' } LIMIT ${limit}`; diff --git a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts index f300a9a0ab..323bf92ddb 100644 --- a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts +++ b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts @@ -7,6 +7,7 @@ import { INodePropertyOptions, INodeType, INodeTypeDescription, + LoggerProxy as Logger, NodeApiError, NodeOperationError, } from 'n8n-workflow'; @@ -60,8 +61,6 @@ import { userFields, userOperations } from './UserDescription'; import { documentFields, documentOperations } from './DocumentDescription'; -import { LoggerProxy as Logger } from 'n8n-workflow'; - export class Salesforce implements INodeType { description: INodeTypeDescription = { displayName: 'Salesforce', @@ -1291,7 +1290,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, 'Lead', returnAll) as string; + qs.q = getQuery(options, 'Lead', returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -1302,7 +1301,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, 'Lead', returnAll, limit) as string; + qs.q = getQuery(options, 'Lead', returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -1637,7 +1636,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, 'Contact', returnAll) as string; + qs.q = getQuery(options, 'Contact', returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -1648,7 +1647,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, 'Contact', returnAll, limit) as string; + qs.q = getQuery(options, 'Contact', returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -1727,8 +1726,7 @@ export class Salesforce implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); const body: IDataObject = {}; if (customFieldsUi) { - const customFields = (customFieldsUi as IDataObject) - .customFieldsValues as IDataObject[]; + const customFields = customFieldsUi.customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1762,8 +1760,7 @@ export class Salesforce implements INodeType { body.RecordTypeId = updateFields.recordTypeId as string; } if (customFieldsUi) { - const customFields = (customFieldsUi as IDataObject) - .customFieldsValues as IDataObject[]; + const customFields = customFieldsUi.customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1793,7 +1790,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, customObject, returnAll) as string; + qs.q = getQuery(options, customObject, returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -1804,7 +1801,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, customObject, returnAll, limit) as string; + qs.q = getQuery(options, customObject, returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -1846,17 +1843,17 @@ export class Salesforce implements INodeType { }, }; if (additionalFields.ownerId) { - body.entity_content['ownerId'] = additionalFields.ownerId as string; + body.entity_content.ownerId = additionalFields.ownerId as string; } if (additionalFields.linkToObjectId) { - body.entity_content['FirstPublishLocationId'] = + body.entity_content.FirstPublishLocationId = additionalFields.linkToObjectId as string; } if (items[i].binary && items[i].binary![binaryPropertyName]) { const binaryData = items[i].binary![binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); - body.entity_content['PathOnClient'] = `${title}.${ + body.entity_content.PathOnClient = `${title}.${ additionalFields.fileExtension || binaryData.fileExtension }`; data = { @@ -1869,7 +1866,7 @@ export class Salesforce implements INodeType { VersionData: { value: dataBuffer, options: { - filename: body.entity_content['PathOnClient'], + filename: body.entity_content.PathOnClient, }, }, }; @@ -2038,7 +2035,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, 'Opportunity', returnAll) as string; + qs.q = getQuery(options, 'Opportunity', returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2049,7 +2046,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, 'Opportunity', returnAll, limit) as string; + qs.q = getQuery(options, 'Opportunity', returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2328,7 +2325,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, 'Account', returnAll) as string; + qs.q = getQuery(options, 'Account', returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2339,7 +2336,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, 'Account', returnAll, limit) as string; + qs.q = getQuery(options, 'Account', returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2543,7 +2540,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, 'Case', returnAll) as string; + qs.q = getQuery(options, 'Case', returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2554,7 +2551,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, 'Case', returnAll, limit) as string; + qs.q = getQuery(options, 'Case', returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2806,7 +2803,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, 'Task', returnAll) as string; + qs.q = getQuery(options, 'Task', returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2817,7 +2814,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, 'Task', returnAll, limit) as string; + qs.q = getQuery(options, 'Task', returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2938,7 +2935,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, 'Attachment', returnAll) as string; + qs.q = getQuery(options, 'Attachment', returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2949,7 +2946,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, 'Attachment', returnAll, limit) as string; + qs.q = getQuery(options, 'Attachment', returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -2993,7 +2990,7 @@ export class Salesforce implements INodeType { const options = this.getNodeParameter('options', i); try { if (returnAll) { - qs.q = getQuery(options, 'User', returnAll) as string; + qs.q = getQuery(options, 'User', returnAll); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -3004,7 +3001,7 @@ export class Salesforce implements INodeType { ); } else { const limit = this.getNodeParameter('limit', i); - qs.q = getQuery(options, 'User', returnAll, limit) as string; + qs.q = getQuery(options, 'User', returnAll, limit); responseData = await salesforceApiRequestAllItems.call( this, 'records', @@ -3030,11 +3027,10 @@ export class Salesforce implements INodeType { } else { // Input variables are defined in UI const setInputVariable = this.getNodeParameter('variablesUi', i, {}) as IDataObject; - if (setInputVariable!.variablesValues !== undefined) { - for (const inputVariableData of setInputVariable! - .variablesValues as IDataObject[]) { + if (setInputVariable.variablesValues !== undefined) { + for (const inputVariableData of setInputVariable.variablesValues as IDataObject[]) { // @ts-ignore - variables[inputVariableData!.name as string] = inputVariableData!.value; + variables[inputVariableData.name as string] = inputVariableData.value; } } } @@ -3053,7 +3049,7 @@ export class Salesforce implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); responseData = await salesforceApiRequest.call(this, 'GET', '/actions/custom/flow'); responseData = responseData.actions; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } diff --git a/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts b/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts index 92bab924c3..3378bf8057 100644 --- a/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts +++ b/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts @@ -305,7 +305,7 @@ export class Salesmate implements INodeType { itemIndex: i, }); } - body.fields = (options.fields as string).split(',') as string[]; + body.fields = (options.fields as string).split(','); } else { body.fields = [ 'name', @@ -325,9 +325,8 @@ export class Salesmate implements INodeType { } if (!jsonActive) { const filters: IDataObject[] = []; - const filtersUi = (this.getNodeParameter('filters', i) as IDataObject) - .filtersUi as IDataObject; - if (filtersUi && filtersUi.conditions) { + const filtersUi = this.getNodeParameter('filters', i).filtersUi as IDataObject; + if (filtersUi?.conditions) { const conditions = filtersUi.conditions as IDataObject; if (conditions.conditionsUi) { for (const condition of conditions.conditionsUi as IDataObject[]) { @@ -342,7 +341,7 @@ export class Salesmate implements INodeType { } } } - if (filtersUi && filtersUi.operator) { + if (filtersUi?.operator) { //@ts-ignore body.query.group = { operator: filtersUi.operator, @@ -498,7 +497,7 @@ export class Salesmate implements INodeType { itemIndex: i, }); } - body.fields = (options.fields as string).split(',') as string[]; + body.fields = (options.fields as string).split(','); } else { body.fields = [ 'title', @@ -519,9 +518,8 @@ export class Salesmate implements INodeType { } if (!jsonActive) { const filters: IDataObject[] = []; - const filtersUi = (this.getNodeParameter('filters', i) as IDataObject) - .filtersUi as IDataObject; - if (filtersUi && filtersUi.conditions) { + const filtersUi = this.getNodeParameter('filters', i).filtersUi as IDataObject; + if (filtersUi?.conditions) { const conditions = filtersUi.conditions as IDataObject; if (conditions.conditionsUi) { for (const condition of conditions.conditionsUi as IDataObject[]) { @@ -536,7 +534,7 @@ export class Salesmate implements INodeType { } } } - if (filtersUi && filtersUi.operator) { + if (filtersUi?.operator) { //@ts-ignore body.query.group = { operator: filtersUi.operator, @@ -709,7 +707,7 @@ export class Salesmate implements INodeType { itemIndex: i, }); } - body.fields = (options.fields as string).split(',') as string[]; + body.fields = (options.fields as string).split(','); } else { body.fields = [ 'title', @@ -728,9 +726,8 @@ export class Salesmate implements INodeType { } if (!jsonActive) { const filters: IDataObject[] = []; - const filtersUi = (this.getNodeParameter('filters', i) as IDataObject) - .filtersUi as IDataObject; - if (filtersUi && filtersUi.conditions) { + const filtersUi = this.getNodeParameter('filters', i).filtersUi as IDataObject; + if (filtersUi?.conditions) { const conditions = filtersUi.conditions as IDataObject; if (conditions.conditionsUi) { for (const condition of conditions.conditionsUi as IDataObject[]) { @@ -745,7 +742,7 @@ export class Salesmate implements INodeType { } } } - if (filtersUi && filtersUi.operator) { + if (filtersUi?.operator) { //@ts-ignore body.query.group = { operator: filtersUi.operator, diff --git a/packages/nodes-base/nodes/Schedule/ScheduleTrigger.node.ts b/packages/nodes-base/nodes/Schedule/ScheduleTrigger.node.ts index 9ae148c2d1..a65ce0c817 100644 --- a/packages/nodes-base/nodes/Schedule/ScheduleTrigger.node.ts +++ b/packages/nodes-base/nodes/Schedule/ScheduleTrigger.node.ts @@ -508,7 +508,7 @@ export class ScheduleTrigger implements INodeType { const minute = interval[i].triggerAtMinute?.toString() as string; const week = interval[i].weeksInterval as number; const days = interval[i].triggerAtDay as IDataObject[]; - const day = days.length === 0 ? '*' : (days.join(',') as string); + const day = days.length === 0 ? '*' : days.join(','); const cronTimes: string[] = [minute, hour, '*', '*', day]; const cronExpression = cronTimes.join(' '); if (week === 1) { @@ -542,8 +542,8 @@ export class ScheduleTrigger implements INodeType { for (const cronJob of cronJobs) { cronJob.stop(); } - for (const interval of intervalArr) { - clearInterval(interval); + for (const entry of intervalArr) { + clearInterval(entry); } } diff --git a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts index 9e7e90a00b..caa0d75b00 100644 --- a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts @@ -4,12 +4,7 @@ import { OptionsWithUri } from 'request'; import { IDataObject, ILoadOptionsFunctions, IPollFunctions, NodeApiError } from 'n8n-workflow'; -import { - TDtableMetadataColumns, - TDtableViewColumns, - TEndpointResolvedExpr, - TEndpointVariableName, -} from './types'; +import { TDtableMetadataColumns, TDtableViewColumns, TEndpointVariableName } from './types'; import { schema } from './Schema'; @@ -63,7 +58,7 @@ export async function seaTableApiRequest( try { //@ts-ignore - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -197,7 +192,7 @@ const uniquePredicate = (current: string, index: number, all: string[]) => all.indexOf(current) === index; const nonInternalPredicate = (name: string) => !Object.keys(schema.internalNames).includes(name); const namePredicate = (name: string) => (named: IName) => named.name === name; -export const nameOfPredicate = (names: ReadonlyArray) => (name: string) => +export const nameOfPredicate = (names: readonly IName[]) => (name: string) => names.find(namePredicate(name)); export function columnNamesToArray(columnNames: string): string[] { @@ -227,7 +222,7 @@ export function rowsSequence(rows: IRow[]) { const l = rows.length; if (l) { const [first] = rows; - if (first && first._seq !== undefined) { + if (first?._seq !== undefined) { return; } } @@ -314,7 +309,7 @@ export const dtableSchemaColumns = (columns: TDtableMetadataColumns): TDtableMet export const updateAble = (columns: TDtableMetadataColumns): TDtableMetadataColumns => columns.filter(dtableSchemaIsUpdateAbleColumn); -function endpointCtxExpr(this: void, ctx: ICtx, endpoint: string): string { +function endpointCtxExpr(ctx: ICtx, endpoint: string): string { const endpointVariables: IEndpointVariables = {}; endpointVariables.access_token = ctx?.base?.access_token; endpointVariables.dtable_uuid = ctx?.base?.dtable_uuid; @@ -324,7 +319,7 @@ function endpointCtxExpr(this: void, ctx: ICtx, endpoint: string): string { (match: string, expr: string, name: TEndpointVariableName) => { return endpointVariables[name] || match; }, - ) as TEndpointResolvedExpr; + ); } const normalize = (subject: string): string => (subject ? subject.normalize() : ''); diff --git a/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts b/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts index 81f9d0fb2d..25b7a15471 100644 --- a/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts +++ b/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts @@ -343,7 +343,7 @@ export class SeaTable implements INodeType { try { const tableName = this.getNodeParameter('tableName', 0) as string; const rowId = this.getNodeParameter('rowId', i) as string; - const body: IDataObject = { + const requestBody: IDataObject = { table_name: tableName, row_id: rowId, }; @@ -352,7 +352,7 @@ export class SeaTable implements INodeType { ctx, 'DELETE', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/`, - body, + requestBody, qs, )) as IDataObject; diff --git a/packages/nodes-base/nodes/SeaTable/SeaTableTrigger.node.ts b/packages/nodes-base/nodes/SeaTable/SeaTableTrigger.node.ts index 4d23e36609..56c1455743 100644 --- a/packages/nodes-base/nodes/SeaTable/SeaTableTrigger.node.ts +++ b/packages/nodes-base/nodes/SeaTable/SeaTableTrigger.node.ts @@ -136,7 +136,7 @@ export class SeaTableTrigger implements INodeType { if (rows.metadata && rows.results) { const columns = getColumns(rows); - if (simple === true) { + if (simple) { response = simplify(rows, columns); } else { response = rows.results; diff --git a/packages/nodes-base/nodes/SeaTable/types.d.ts b/packages/nodes-base/nodes/SeaTable/types.d.ts index eb4eed2aa8..105123b4e0 100644 --- a/packages/nodes-base/nodes/SeaTable/types.d.ts +++ b/packages/nodes-base/nodes/SeaTable/types.d.ts @@ -44,9 +44,9 @@ type TInheritColumnKey = type TColumnValue = undefined | boolean | number | string | string[] | null; type TColumnKey = TInheritColumnKey | string; -export type TDtableMetadataTables = ReadonlyArray; -export type TDtableMetadataColumns = ReadonlyArray; -export type TDtableViewColumns = ReadonlyArray; +export type TDtableMetadataTables = readonly IDtableMetadataTable[]; +export type TDtableMetadataColumns = readonly IDtableMetadataColumn[]; +export type TDtableViewColumns = readonly TDtableViewColumn[]; // ---------------------------------- // api diff --git a/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts b/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts index d712117d25..af6a5a9e93 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts @@ -159,7 +159,7 @@ export class SecurityScorecard implements INodeType { responseData = await scorecardApiRequest.call(this, 'GET', 'portfolios'); responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.splice(0, limit); } @@ -205,7 +205,7 @@ export class SecurityScorecard implements INodeType { responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', 0); responseData = responseData.splice(0, limit); } @@ -259,18 +259,18 @@ export class SecurityScorecard implements INodeType { let body: IDataObject = {}; if (reportType !== 'portfolio') { - body['scorecard_identifier'] = this.getNodeParameter('scorecardIdentifier', i); + body.scorecard_identifier = this.getNodeParameter('scorecardIdentifier', i); } else { - body['portfolio_id'] = this.getNodeParameter('portfolioId', i); + body.portfolio_id = this.getNodeParameter('portfolioId', i); } if (reportType === 'events-json') { - body['date'] = this.getNodeParameter('date', i); + body.date = this.getNodeParameter('date', i); } if (['issues', 'portfolio'].indexOf(reportType) > -1) { - body['format'] = this.getNodeParameter('options.format', i) || 'pdf'; + body.format = this.getNodeParameter('options.format', i) || 'pdf'; } if (['detailed', 'summary'].indexOf(reportType) > -1) { - body['branding'] = this.getNodeParameter('branding', i); + body.branding = this.getNodeParameter('branding', i); } // json reports want the params differently if (['events-json', 'full-scorecard-json'].indexOf(reportType) > -1) { @@ -296,7 +296,7 @@ export class SecurityScorecard implements INodeType { responseData = await scorecardApiRequest.call(this, 'GET', 'reports/recent'); responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -342,12 +342,12 @@ export class SecurityScorecard implements INodeType { ); responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } - if (simple === true) { + if (simple) { responseData = simplify(responseData); } @@ -360,12 +360,12 @@ export class SecurityScorecard implements INodeType { const industry = this.getNodeParameter('industry', i); const options = this.getNodeParameter('options', i); // Convert to YYYY-MM-DD - if (options['from']) { - options['from'] = moment(options['from'] as Date).format('YYYY-MM-DD'); + if (options.from) { + options.from = moment(options.from as Date).format('YYYY-MM-DD'); } - if (options['to']) { - options['to'] = moment(options['to'] as Date).format('YYYY-MM-DD'); + if (options.to) { + options.to = moment(options.to as Date).format('YYYY-MM-DD'); } responseData = await scorecardApiRequest.call( this, @@ -376,12 +376,12 @@ export class SecurityScorecard implements INodeType { ); responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } - if (simple === true) { + if (simple) { responseData = simplify(responseData); } @@ -414,7 +414,7 @@ export class SecurityScorecard implements INodeType { responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -428,12 +428,12 @@ export class SecurityScorecard implements INodeType { const scorecardIdentifier = this.getNodeParameter('scorecardIdentifier', i) as string; const options = this.getNodeParameter('options', i); // Convert to YYYY-MM-DD - if (options['date_from']) { - options['date_from'] = moment(options['date_from'] as Date).format('YYYY-MM-DD'); + if (options.date_from) { + options.date_from = moment(options.date_from as Date).format('YYYY-MM-DD'); } - if (options['date_to']) { - options['date_to'] = moment(options['date_to'] as Date).format('YYYY-MM-DD'); + if (options.date_to) { + options.date_to = moment(options.date_to as Date).format('YYYY-MM-DD'); } responseData = await scorecardApiRequest.call( this, @@ -445,12 +445,12 @@ export class SecurityScorecard implements INodeType { responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } - if (simple === true) { + if (simple) { responseData = simplify(responseData); } @@ -464,13 +464,13 @@ export class SecurityScorecard implements INodeType { const options = this.getNodeParameter('options', i); // for some reason the params are different between these two APis :/ - if (options['date_from']) { - options['from'] = moment(options['date_from'] as Date).format('YYYY-MM-DD'); - delete options['date_from']; + if (options.date_from) { + options.from = moment(options.date_from as Date).format('YYYY-MM-DD'); + delete options.date_from; } - if (options['date_to']) { - options['to'] = moment(options['date_to'] as Date).format('YYYY-MM-DD'); - delete options['date_to']; + if (options.date_to) { + options.to = moment(options.date_to as Date).format('YYYY-MM-DD'); + delete options.date_to; } responseData = await scorecardApiRequest.call( this, @@ -481,12 +481,12 @@ export class SecurityScorecard implements INodeType { ); responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } - if (simple === true) { + if (simple) { responseData = simplify(responseData); } @@ -505,7 +505,7 @@ export class SecurityScorecard implements INodeType { responseData = responseData.entries; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } diff --git a/packages/nodes-base/nodes/Segment/Segment.node.ts b/packages/nodes-base/nodes/Segment/Segment.node.ts index 6df4c76280..a98d599d66 100644 --- a/packages/nodes-base/nodes/Segment/Segment.node.ts +++ b/packages/nodes-base/nodes/Segment/Segment.node.ts @@ -105,7 +105,7 @@ export class Segment implements INodeType { integrations: {}, }; if (userId) { - body.userId = userId as string; + body.userId = userId; } else { body.anonymousId = uuid(); } @@ -235,7 +235,7 @@ export class Segment implements INodeType { integrations: {}, }; if (userId) { - body.userId = userId as string; + body.userId = userId; } else { body.anonymousId = uuid(); } @@ -370,7 +370,7 @@ export class Segment implements INodeType { properties: {}, }; if (userId) { - body.userId = userId as string; + body.userId = userId; } else { body.anonymousId = uuid(); } @@ -502,7 +502,7 @@ export class Segment implements INodeType { properties: {}, }; if (userId) { - body.userId = userId as string; + body.userId = userId; } else { body.anonymousId = uuid(); } diff --git a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts index 08c3ceee3f..40c81638d3 100644 --- a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts +++ b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts @@ -163,7 +163,7 @@ export class SendGrid implements INodeType { body, qs, ); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -271,9 +271,9 @@ export class SendGrid implements INodeType { Object.assign(contact, { state_province_region: stateProvinceRegion }); } if (additionalFields.alternateEmails) { - const alternateEmails = ( - (additionalFields.alternateEmails as string).split(',') as string[] - ).filter((email) => !!email); + const alternateEmails = (additionalFields.alternateEmails as string) + .split(',') + .filter((mail) => !!mail); if (alternateEmails.length !== 0) { Object.assign(contact, { alternate_emails: alternateEmails }); } @@ -317,7 +317,7 @@ export class SendGrid implements INodeType { for (let i = 0; i < length; i++) { try { const deleteAll = this.getNodeParameter('deleteAll', i) as boolean; - if (deleteAll === true) { + if (deleteAll) { qs.delete_all_contacts = 'true'; } qs.ids = (this.getNodeParameter('ids', i) as string).replace(/\s/g, ''); @@ -361,7 +361,7 @@ export class SendGrid implements INodeType { {}, qs, ); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -514,7 +514,7 @@ export class SendGrid implements INodeType { const toEmail = this.getNodeParameter('toEmail', i) as string; const parsedToEmail = toEmail.includes(',') - ? toEmail.split(',').map((i) => ({ email: i.trim() })) + ? toEmail.split(',').map((entry) => ({ email: entry.trim() })) : [{ email: toEmail.trim() }]; const { @@ -612,25 +612,29 @@ export class SendGrid implements INodeType { } if (bccEmail) { - body.personalizations[0].bcc = bccEmail.split(',').map((i) => ({ email: i.trim() })); + body.personalizations[0].bcc = bccEmail + .split(',') + .map((entry) => ({ email: entry.trim() })); } if (ccEmail) { - body.personalizations[0].cc = ccEmail.split(',').map((i) => ({ email: i.trim() })); + body.personalizations[0].cc = ccEmail + .split(',') + .map((entry) => ({ email: entry.trim() })); } if (headers?.details.length) { const parsedHeaders: { [key: string]: string } = {}; - headers.details.forEach((obj) => (parsedHeaders[obj['key']] = obj['value'])); + headers.details.forEach((obj) => (parsedHeaders[obj.key] = obj.value)); body.headers = parsedHeaders; } if (categories) { - body.categories = categories.split(',') as string[]; + body.categories = categories.split(','); } if (ipPoolName) { - body.ip_pool_name = ipPoolName as string; + body.ip_pool_name = ipPoolName; } if (sendAt) { @@ -642,7 +646,7 @@ export class SendGrid implements INodeType { }); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray({ messageId: data!.headers['x-message-id'] }), + this.helpers.returnJsonArray({ messageId: data.headers['x-message-id'] }), { 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 f61ddc4b1e..acd8e04cb3 100644 --- a/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts @@ -35,19 +35,19 @@ export namespace SendInBlueNode { [ OVERRIDE_MAP_TYPE.CATEGORY, (body: JsonObject) => { - body!.type = OVERRIDE_MAP_VALUES.CATEGORY; + body.type = OVERRIDE_MAP_VALUES.CATEGORY; }, ], [ OVERRIDE_MAP_TYPE.NORMAL, (body: JsonObject) => { - body!.type = OVERRIDE_MAP_VALUES.NORMAL; + body.type = OVERRIDE_MAP_VALUES.NORMAL; }, ], [ OVERRIDE_MAP_TYPE.TRANSACTIONAL, (body: JsonObject) => { - body!.type = OVERRIDE_MAP_VALUES.TRANSACTIONAL; + body.type = OVERRIDE_MAP_VALUES.TRANSACTIONAL; }, ], ]); @@ -67,19 +67,19 @@ export namespace SendInBlueNode { const { binaryPropertyName } = dataPropertyList; const dataMappingList = (binaryPropertyName as string).split(','); for (const attachmentDataName of dataMappingList) { - const binaryPropertyName = attachmentDataName; + const binaryPropertyAttachmentName = attachmentDataName; const item = this.getInputData(); - if (item.binary![binaryPropertyName as string] === undefined) { + if (item.binary![binaryPropertyAttachmentName] === undefined) { throw new NodeOperationError( this.getNode(), - `No binary data property “${binaryPropertyName}” exists on item!`, + `No binary data property “${binaryPropertyAttachmentName}” exists on item!`, ); } const bufferFromIncomingData = (await this.helpers.getBinaryDataBuffer( - binaryPropertyName, + binaryPropertyAttachmentName, )) as Buffer; const { @@ -115,9 +115,9 @@ export namespace SendInBlueNode { const { tag } = this.getNodeParameter('additionalFields.emailTags.tags') as JsonObject; const tags = (tag as string) .split(',') - .map((tag) => tag.trim()) - .filter((tag) => { - return tag !== ''; + .map((entry) => entry.trim()) + .filter((entry) => { + return entry !== ''; }); const { body } = requestOptions; Object.assign(body!, { tags }); @@ -338,7 +338,7 @@ export namespace SendInBlueWebhookApi { options, )) as string; - return jsonParse(webhooks) as Webhooks; + return jsonParse(webhooks); }; export const createWebHook = async ( @@ -368,7 +368,7 @@ export namespace SendInBlueWebhookApi { options, ); - return jsonParse(webhookId) as WebhookId; + return jsonParse(webhookId); }; export const deleteWebhook = async (ref: IHookFunctions, webhookId: string) => { @@ -384,6 +384,6 @@ export namespace SendInBlueWebhookApi { body, }; - return await ref.helpers.requestWithAuthentication.call(ref, credentialsName, options); + return ref.helpers.requestWithAuthentication.call(ref, credentialsName, options); }; } diff --git a/packages/nodes-base/nodes/SendInBlue/SendInBlueTrigger.node.ts b/packages/nodes-base/nodes/SendInBlue/SendInBlueTrigger.node.ts index 8a9a20f77a..2ff0c2dc4f 100644 --- a/packages/nodes-base/nodes/SendInBlue/SendInBlueTrigger.node.ts +++ b/packages/nodes-base/nodes/SendInBlue/SendInBlueTrigger.node.ts @@ -1,6 +1,5 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ import { - IDataObject, IHookFunctions, INodeType, INodeTypeDescription, @@ -282,7 +281,7 @@ export class SendInBlueTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { // The data to return and so start the workflow with - const bodyData = this.getBodyData() as IDataObject; + const bodyData = this.getBodyData(); return { workflowData: [this.helpers.returnJsonArray(bodyData)], diff --git a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts index a54ecdd03e..02ca6f5dd2 100644 --- a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts @@ -70,7 +70,7 @@ export async function sentryIoApiRequest( }; //@ts-ignore - return this.helpers.request(options); + return await this.helpers.request(options); } else { return await this.helpers.requestOAuth2!.call(this, 'sentryIoOAuth2Api', options); } diff --git a/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts b/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts index 942eaaa7eb..525cb62a48 100644 --- a/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts +++ b/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts @@ -301,7 +301,7 @@ export class SentryIo implements INodeType { const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/events/`; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; } @@ -310,7 +310,7 @@ export class SentryIo implements INodeType { responseData = await sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -345,14 +345,14 @@ export class SentryIo implements INodeType { qs.query = additionalFields.query as string; } - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; } responseData = await sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -417,7 +417,7 @@ export class SentryIo implements INodeType { qs.owner = additionalFields.owner as boolean; } - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; } @@ -428,7 +428,7 @@ export class SentryIo implements INodeType { responseData = []; } - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -467,7 +467,7 @@ export class SentryIo implements INodeType { const body = { name, - ...(this.getNodeParameter('additionalFields', i) as IDataObject), + ...this.getNodeParameter('additionalFields', i), }; responseData = await sentryIoApiRequest.call(this, 'POST', endpoint, body, qs); @@ -483,14 +483,14 @@ export class SentryIo implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); const endpoint = `/api/0/projects/`; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; } responseData = await sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -530,14 +530,14 @@ export class SentryIo implements INodeType { qs.query = additionalFields.query as string; } - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; } responseData = await sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } @@ -679,14 +679,14 @@ export class SentryIo implements INodeType { const endpoint = `/api/0/organizations/${organizationSlug}/teams/`; const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; } responseData = await sentryApiRequestAllItems.call(this, 'GET', endpoint, {}, qs); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } diff --git a/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts b/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts index 85d485cf14..40d9f15ac0 100644 --- a/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts +++ b/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts @@ -621,7 +621,7 @@ export class ServiceNow implements INodeType { 'Content-Type': binaryData.mimeType, }; - const qs: IDataObject = { + const query: IDataObject = { table_name: tableName, table_sys_id: recordId, file_name: binaryData.fileName @@ -630,14 +630,14 @@ export class ServiceNow implements INodeType { ...options, }; - const body = (await this.helpers.getBinaryDataBuffer(i, inputDataFieldName)) as Buffer; + const body = await this.helpers.getBinaryDataBuffer(i, inputDataFieldName); const response = await serviceNowApiRequest.call( this, 'POST', '/now/attachment/file', body, - qs, + query, '', { headers }, ); @@ -1171,7 +1171,7 @@ export class ServiceNow implements INodeType { if (resource === 'attachment') { if (operation === 'get' || operation === 'getAll') { - return this.prepareOutputData(returnData as INodeExecutionData[]); + return this.prepareOutputData(returnData); } } return this.prepareOutputData(returnData); diff --git a/packages/nodes-base/nodes/Set/Set.node.ts b/packages/nodes-base/nodes/Set/Set.node.ts index 87ef394f7d..7de37ec2ab 100644 --- a/packages/nodes-base/nodes/Set/Set.node.ts +++ b/packages/nodes-base/nodes/Set/Set.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { deepCopy, - IDataObject, INodeExecutionData, INodeParameters, INodeType, @@ -133,7 +132,7 @@ export class Set implements INodeType { ], }; - execute(this: IExecuteFunctions): Promise { + async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); if (items.length === 0) { @@ -147,14 +146,14 @@ export class Set implements INodeType { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { keepOnlySet = this.getNodeParameter('keepOnlySet', itemIndex, false) as boolean; item = items[itemIndex]; - const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}); const newItem: INodeExecutionData = { json: {}, pairedItem: item.pairedItem, }; - if (keepOnlySet !== true) { + if (!keepOnlySet) { if (item.binary !== undefined) { // Create a shallow copy of the binary data so that the old // data references which do not get changed still stay behind diff --git a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts index d839bf65de..3d035fef97 100644 --- a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts @@ -102,13 +102,10 @@ export async function shopifyApiRequestAllItems( resolveWithFullResponse: true, }); if (responseData.headers.link) { - uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', ''); + uri = responseData.headers.link.split(';')[0].replace('<', '').replace('>', ''); } returnData.push.apply(returnData, responseData.body[propertyName]); - } while ( - responseData.headers['link'] !== undefined && - responseData.headers['link'].includes('rel="next"') - ); + } 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 0123663f62..17d6d189fb 100644 --- a/packages/nodes-base/nodes/Shopify/Shopify.node.ts +++ b/packages/nodes-base/nodes/Shopify/Shopify.node.ts @@ -306,7 +306,7 @@ export class Shopify implements INodeType { qs.fulfillment_status = options.fulfillmentStatus as string; } - if (returnAll === true) { + if (returnAll) { responseData = await shopifyApiRequestAllItems.call( this, 'orders', @@ -359,11 +359,7 @@ export class Shopify implements INodeType { if (operation === 'create') { const title = this.getNodeParameter('title', i) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - {}, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); if (additionalFields.productOptions) { const metadata = (additionalFields.productOptions as IDataObject) @@ -396,11 +392,7 @@ export class Shopify implements INodeType { } if (operation === 'get') { //https://shopify.dev/docs/admin-api/rest/reference/products/product#show-2020-04 - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - {}, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); Object.assign(qs, additionalFields); responseData = await shopifyApiRequest.call( this, @@ -413,17 +405,13 @@ export class Shopify implements INodeType { } if (operation === 'getAll') { //https://shopify.dev/docs/admin-api/rest/reference/products/product#index-2020-04 - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - {}, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); const returnAll = this.getNodeParameter('returnAll', i); Object.assign(qs, additionalFields); - if (returnAll === true) { + if (returnAll) { responseData = await shopifyApiRequestAllItems.call( this, 'products', @@ -440,7 +428,7 @@ export class Shopify implements INodeType { } if (operation === 'update') { //https://shopify.dev/docs/admin-api/rest/reference/products/product?api[version]=2020-07#update-2020-07 - const updateFields = this.getNodeParameter('updateFields', i, {}) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i, {}); if (updateFields.productOptions) { const metadata = (updateFields.productOptions as IDataObject).option as IDataObject[]; diff --git a/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts b/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts index 1168f658a7..217eb9b6c9 100644 --- a/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts +++ b/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts @@ -325,6 +325,7 @@ export class ShopifyTrigger implements INodeType { }, ], }; + // @ts-ignore (because of request) webhookMethods = { default: { @@ -356,9 +357,7 @@ export class ShopifyTrigger implements INodeType { }, }; - let responseData; - - responseData = await shopifyApiRequest.call(this, 'POST', endpoint, body); + const responseData = await shopifyApiRequest.call(this, 'POST', endpoint, body); if (responseData.webhook === undefined || responseData.webhook.id === undefined) { // Required data is missing so was not successful diff --git a/packages/nodes-base/nodes/Signl4/GenericFunctions.ts b/packages/nodes-base/nodes/Signl4/GenericFunctions.ts index 8f6816f3f6..76da4127c7 100644 --- a/packages/nodes-base/nodes/Signl4/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Signl4/GenericFunctions.ts @@ -42,7 +42,7 @@ export async function SIGNL4ApiRequest( options = Object.assign({}, options, option); try { - return await this.helpers.request!(options); + return await this.helpers.request(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Slack/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/GenericFunctions.ts index e96409c344..b0f9a03e1d 100644 --- a/packages/nodes-base/nodes/Slack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/GenericFunctions.ts @@ -18,8 +18,9 @@ export async function slackApiRequest( resource: string, body: object = {}, query: object = {}, - headers: {} | undefined = undefined, - option: {} = {}, + headers: IDataObject | undefined = undefined, + option: IDataObject = {}, + // tslint:disable-next-line:no-any ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; let options: OptionsWithUri = { @@ -46,11 +47,15 @@ export async function slackApiRequest( }; try { - let response: any; const credentialType = authenticationMethod === 'accessToken' ? 'slackApi' : 'slackOAuth2Api'; - response = await this.helpers.requestWithAuthentication.call(this, credentialType, options, { - oauth2: oAuth2Options, - }); + const response = await this.helpers.requestWithAuthentication.call( + this, + credentialType, + options, + { + oauth2: oAuth2Options, + }, + ); if (response.ok === false) { if (response.error === 'paid_teams_only') { @@ -103,12 +108,10 @@ export async function slackApiRequestAllItems( query.page++; returnData.push.apply(returnData, responseData[propertyName]); } while ( - (responseData.response_metadata !== undefined && - responseData.response_metadata.next_cursor !== undefined && + (responseData.response_metadata?.next_cursor !== undefined && responseData.response_metadata.next_cursor !== '' && responseData.response_metadata.next_cursor !== null) || - (responseData.paging !== undefined && - responseData.paging.pages !== undefined && + (responseData.paging?.pages !== undefined && responseData.paging.page !== undefined && responseData.paging.page < responseData.paging.pages) ); diff --git a/packages/nodes-base/nodes/Slack/Slack.node.ts b/packages/nodes-base/nodes/Slack/Slack.node.ts index 96c8ae6e25..1c8532725f 100644 --- a/packages/nodes-base/nodes/Slack/Slack.node.ts +++ b/packages/nodes-base/nodes/Slack/Slack.node.ts @@ -371,7 +371,7 @@ export class Slack implements INodeType { if (filters.excludeArchived) { qs.exclude_archived = filters.excludeArchived as boolean; } - if (returnAll === true) { + if (returnAll) { responseData = await slackApiRequestAllItems.call( this, 'channels', @@ -401,7 +401,7 @@ export class Slack implements INodeType { if (filters.oldest) { qs.oldest = new Date(filters.oldest as string).getTime() / 1000; } - if (returnAll === true) { + if (returnAll) { responseData = await slackApiRequestAllItems.call( this, 'messages', @@ -551,7 +551,7 @@ export class Slack implements INodeType { if (filters.oldest) { qs.oldest = new Date(filters.oldest as string).getTime() / 1000; } - if (returnAll === true) { + if (returnAll) { responseData = await slackApiRequestAllItems.call( this, 'messages', @@ -669,7 +669,7 @@ export class Slack implements INodeType { } } } - body['attachments'] = attachments; + body.attachments = attachments; if (blocksUi) { const blocks: Block[] = []; @@ -750,7 +750,7 @@ export class Slack implements INodeType { }; } if (style !== 'default') { - confirm.style = style as string; + confirm.style = style; } element.confirm = confirm; } @@ -761,16 +761,16 @@ export class Slack implements INodeType { } else if (block.type === 'section') { const textUi = (blockUi.textUi as IDataObject).textValue as IDataObject; if (textUi) { - const text: Text = {}; + const textData: Text = {}; if (textUi.type === 'plainText') { - text.type = 'plain_text'; - text.emoji = textUi.emoji as boolean; + textData.type = 'plain_text'; + textData.emoji = textUi.emoji as boolean; } else { - text.type = 'mrkdwn'; - text.verbatim = textUi.verbatim as boolean; + textData.type = 'mrkdwn'; + textData.verbatim = textUi.verbatim as boolean; } - text.text = textUi.text as string; - block.text = text; + textData.text = textUi.text as string; + block.text = textData; } else { throw new NodeOperationError( this.getNode(), @@ -825,7 +825,8 @@ export class Slack implements INodeType { const confirm: Confirm = {}; const titleUi = (confirmUi.titleUi as IDataObject) .titleValue as IDataObject; - const textUi = (confirmUi.textUi as IDataObject).textValue as IDataObject; + const textUiFromConfirm = (confirmUi.textUi as IDataObject) + .textValue as IDataObject; const confirmTextUi = (confirmUi.confirmTextUi as IDataObject) .confirmValue as IDataObject; const denyUi = (confirmUi.denyUi as IDataObject).denyValue as IDataObject; @@ -837,11 +838,11 @@ export class Slack implements INodeType { emoji: titleUi.emoji as boolean, }; } - if (textUi) { + if (textUiFromConfirm) { confirm.text = { type: 'plain_text', - text: textUi.text as string, - emoji: textUi.emoji as boolean, + text: textUiFromConfirm.text as string, + emoji: textUiFromConfirm.emoji as boolean, }; } if (confirmTextUi) { @@ -859,7 +860,7 @@ export class Slack implements INodeType { }; } if (style !== 'default') { - confirm.style = style as string; + confirm.style = style; } accessory.confirm = confirm; } @@ -928,9 +929,9 @@ export class Slack implements INodeType { } } } - body['attachments'] = attachments; + body.attachments = attachments; - const jsonParameters = this.getNodeParameter('jsonParameters', i, false) as boolean; + const jsonParameters = this.getNodeParameter('jsonParameters', i, false); if (jsonParameters) { const blocksJson = this.getNodeParameter('blocksJson', i, []) as string; @@ -976,11 +977,11 @@ export class Slack implements INodeType { if (operation === 'getPermalink') { const channel = this.getNodeParameter('channelId', i) as string; const timestamp = this.getNodeParameter('timestamp', i) as string; - const qs = { + const query = { channel, message_ts: timestamp, }; - responseData = await slackApiRequest.call(this, 'GET', '/chat.getPermalink', {}, qs); + responseData = await slackApiRequest.call(this, 'GET', '/chat.getPermalink', {}, query); } } if (resource === 'reaction') { @@ -1053,7 +1054,7 @@ export class Slack implements INodeType { //https://api.slack.com/methods/stars.list if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await slackApiRequestAllItems.call( this, 'items', @@ -1159,12 +1160,12 @@ export class Slack implements INodeType { qs.ts_to = filters.tsTo as string; } if (filters.types) { - qs.types = (filters.types as string[]).join(',') as string; + qs.types = (filters.types as string[]).join(','); } if (filters.userId) { qs.user = filters.userId as string; } - if (returnAll === true) { + if (returnAll) { responseData = await slackApiRequestAllItems.call( this, 'files', @@ -1197,7 +1198,7 @@ export class Slack implements INodeType { //https://api.slack.com/methods/users.list if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === true) { + if (returnAll) { responseData = await slackApiRequestAllItems.call( this, 'members', @@ -1280,15 +1281,17 @@ export class Slack implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); - const qs: IDataObject = {}; - - Object.assign(qs, additionalFields); - - responseData = await slackApiRequest.call(this, 'GET', '/usergroups.list', {}, qs); + responseData = await slackApiRequest.call( + this, + 'GET', + '/usergroups.list', + {}, + additionalFields, + ); responseData = responseData.usergroups; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.slice(0, limit); @@ -1358,16 +1361,12 @@ export class Slack implements INodeType { if (operation === 'get') { const additionalFields = this.getNodeParameter('additionalFields', i); - const qs: IDataObject = {}; - - Object.assign(qs, additionalFields); - responseData = await slackApiRequest.call( this, 'POST', '/users.profile.get', undefined, - qs, + additionalFields, ); responseData = responseData.profile; diff --git a/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts b/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts index 389187e3bc..46fbb42808 100644 --- a/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts @@ -2,7 +2,7 @@ import { deepCopy, IDataObject, INodeExecutionData } from 'n8n-workflow'; import snowflake from 'snowflake-sdk'; -export function connect(conn: snowflake.Connection) { +export async function connect(conn: snowflake.Connection) { return new Promise((resolve, reject) => { conn.connect((err, _conn) => { if (!err) { @@ -15,7 +15,7 @@ export function connect(conn: snowflake.Connection) { }); } -export function destroy(conn: snowflake.Connection) { +export async function destroy(conn: snowflake.Connection) { return new Promise((resolve, reject) => { conn.destroy((err, _conn) => { if (!err) { @@ -28,7 +28,11 @@ export function destroy(conn: snowflake.Connection) { }); } -export function execute(conn: snowflake.Connection, sqlText: string, binds: snowflake.InsertBinds) { +export async function execute( + conn: snowflake.Connection, + sqlText: string, + binds: snowflake.InsertBinds, +) { return new Promise((resolve, reject) => { conn.execute({ sqlText, diff --git a/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts b/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts index ad9eaea595..e9ad33c774 100644 --- a/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts +++ b/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts @@ -1,5 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; -import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; +import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; export class SplitInBatches implements INodeType { description: INodeTypeDescription = { @@ -64,7 +64,7 @@ export class SplitInBatches implements INodeType { const returnItems: INodeExecutionData[] = []; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); if (nodeContext.items === undefined || options.reset === true) { // Is the first time the node runs diff --git a/packages/nodes-base/nodes/Splunk/GenericFunctions.ts b/packages/nodes-base/nodes/Splunk/GenericFunctions.ts index fa96cb3926..9e3b6c3856 100644 --- a/packages/nodes-base/nodes/Splunk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Splunk/GenericFunctions.ts @@ -48,7 +48,7 @@ export async function splunkApiRequest( } try { - return await this.helpers.request!(options).then(parseXml); + return this.helpers.request!(options).then(parseXml); } catch (error) { if (error?.cause?.code === 'ECONNREFUSED') { throw new NodeApiError(this.getNode(), { ...error, code: 401 }); @@ -69,7 +69,7 @@ export async function splunkApiRequest( // utils // ---------------------------------------- -export function parseXml(xml: string) { +export async function parseXml(xml: string) { return new Promise((resolve, reject) => { parseString(xml, { explicitArray: false }, (error, result) => { error ? reject(error) : resolve(result); diff --git a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts index fb4a26a8d0..97e8496696 100644 --- a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts @@ -65,7 +65,7 @@ export async function spotifyApiRequestAllItems( return returnData; } } while ( - (responseData['next'] !== null && responseData['next'] !== undefined) || + (responseData.next !== null && responseData.next !== undefined) || (responseData[propertyName.split('.')[0]].next !== null && responseData[propertyName.split('.')[0]].next !== undefined) ); diff --git a/packages/nodes-base/nodes/Spotify/Spotify.node.ts b/packages/nodes-base/nodes/Spotify/Spotify.node.ts index 3c30c66603..1c38499e73 100644 --- a/packages/nodes-base/nodes/Spotify/Spotify.node.ts +++ b/packages/nodes-base/nodes/Spotify/Spotify.node.ts @@ -781,7 +781,7 @@ export class Spotify implements INodeType { const returnData: INodeExecutionData[] = []; // For Post - let body: IDataObject; + const body: IDataObject = {}; // For Query string let qs: IDataObject; @@ -797,7 +797,6 @@ export class Spotify implements INodeType { // Set initial values requestMethod = 'GET'; endpoint = ''; - body = {}; qs = {}; returnAll = false; @@ -983,7 +982,7 @@ export class Spotify implements INodeType { ...filters, }; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); @@ -1059,7 +1058,7 @@ export class Spotify implements INodeType { ...filters, }; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); @@ -1191,7 +1190,7 @@ export class Spotify implements INodeType { ...filters, }; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); @@ -1233,7 +1232,7 @@ export class Spotify implements INodeType { ...filters, }; - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); qs.limit = limit; responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); diff --git a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts index fd1417f331..8aadc753a4 100644 --- a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts +++ b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts @@ -309,7 +309,7 @@ export class SpreadsheetFile implements INodeType { item = items[i]; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; - const options = this.getNodeParameter('options', i, {}) as IDataObject; + const options = this.getNodeParameter('options', i, {}); if (item.binary === undefined || item.binary[binaryPropertyName] === undefined) { // Property did not get found on item @@ -415,7 +415,7 @@ export class SpreadsheetFile implements INodeType { // Write the workflow data to spreadsheet file const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const fileFormat = this.getNodeParameter('fileFormat', 0) as string; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const sheetToJsonOptions: JSON2SheetOpts = {}; if (options.headerRow === false) { sheetToJsonOptions.skipHeader = true; diff --git a/packages/nodes-base/nodes/Ssh/Ssh.node.ts b/packages/nodes-base/nodes/Ssh/Ssh.node.ts index 661bc1fb3a..61bd01897f 100644 --- a/packages/nodes-base/nodes/Ssh/Ssh.node.ts +++ b/packages/nodes-base/nodes/Ssh/Ssh.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, INodeExecutionData, INodeType, INodeTypeDescription, @@ -331,7 +330,7 @@ export class Ssh implements INodeType { items[i] = newItem; - const data = await readFile(path as string); + const data = await readFile(path); items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( data, @@ -353,7 +352,7 @@ export class Ssh implements INodeType { const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; - const binaryData = item.binary[propertyNameUpload] as IBinaryData; + const binaryData = item.binary[propertyNameUpload]; if (item.binary[propertyNameUpload] === undefined) { throw new NodeOperationError( diff --git a/packages/nodes-base/nodes/Stackby/GenericFunction.ts b/packages/nodes-base/nodes/Stackby/GenericFunction.ts index 6f0b8b493a..e7413d7b07 100644 --- a/packages/nodes-base/nodes/Stackby/GenericFunction.ts +++ b/packages/nodes-base/nodes/Stackby/GenericFunction.ts @@ -40,7 +40,7 @@ export async function apiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Stackby/Stackby.node.ts b/packages/nodes-base/nodes/Stackby/Stackby.node.ts index 67a46dc023..dc3c17cc88 100644 --- a/packages/nodes-base/nodes/Stackby/Stackby.node.ts +++ b/packages/nodes-base/nodes/Stackby/Stackby.node.ts @@ -271,9 +271,9 @@ export class Stackby implements INodeType { records[key].push({ field: record }); } - for (const key of Object.keys(records)) { - responseData = await apiRequest.call(this, 'POST', `/rowcreate/${key}`, { - records: records[key], + for (const recordKey of Object.keys(records)) { + responseData = await apiRequest.call(this, 'POST', `/rowcreate/${recordKey}`, { + records: records[recordKey], }); } @@ -302,13 +302,13 @@ export class Stackby implements INodeType { const table = encodeURI(this.getNodeParameter('table', i) as string); const returnAll = this.getNodeParameter('returnAll', 0); - const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i, {}); if (additionalFields.view) { qs.view = additionalFields.view; } - if (returnAll === true) { + if (returnAll) { responseData = await apiRequestAllItems.call( this, 'GET', diff --git a/packages/nodes-base/nodes/Start/Start.node.ts b/packages/nodes-base/nodes/Start/Start.node.ts index 73593925ca..b64f5ba04f 100644 --- a/packages/nodes-base/nodes/Start/Start.node.ts +++ b/packages/nodes-base/nodes/Start/Start.node.ts @@ -29,7 +29,7 @@ export class Start implements INodeType { ], }; - execute(this: IExecuteFunctions): Promise { + async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); return this.prepareOutputData(items); diff --git a/packages/nodes-base/nodes/StickyNote/StickyNote.node.ts b/packages/nodes-base/nodes/StickyNote/StickyNote.node.ts index 32d0140805..c090afa7f7 100644 --- a/packages/nodes-base/nodes/StickyNote/StickyNote.node.ts +++ b/packages/nodes-base/nodes/StickyNote/StickyNote.node.ts @@ -42,7 +42,7 @@ export class StickyNote implements INodeType { ], }; - execute(this: IExecuteFunctions): Promise { + async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); return this.prepareOutputData(items); } diff --git a/packages/nodes-base/nodes/StopAndError/StopAndError.node.ts b/packages/nodes-base/nodes/StopAndError/StopAndError.node.ts index 3e24398754..9f7dd4d15e 100644 --- a/packages/nodes-base/nodes/StopAndError/StopAndError.node.ts +++ b/packages/nodes-base/nodes/StopAndError/StopAndError.node.ts @@ -82,7 +82,7 @@ export class StopAndError implements INodeType { ], }; - execute(this: IExecuteFunctions): Promise { + async execute(this: IExecuteFunctions): Promise { const errorType = this.getNodeParameter('errorType', 0) as 'errorMessage' | 'errorObject'; const { id: workflowId, name: workflowName } = this.getWorkflow(); diff --git a/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts b/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts index 4c46cd8b23..9952e7c00b 100644 --- a/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts @@ -54,7 +54,7 @@ export async function storyblokApiRequest( } try { - return this.helpers.request!(options); + return await this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Strapi/Strapi.node.ts b/packages/nodes-base/nodes/Strapi/Strapi.node.ts index 1ed5341915..8cea92df35 100644 --- a/packages/nodes-base/nodes/Strapi/Strapi.node.ts +++ b/packages/nodes-base/nodes/Strapi/Strapi.node.ts @@ -68,7 +68,7 @@ export class Strapi implements INodeType { this: ICredentialTestFunctions, credential: ICredentialsDecrypted, ): Promise { - const credentials = (await credential.data) as IDataObject; + const credentials = credential.data as IDataObject; let options = {} as OptionsWithUri; options = { diff --git a/packages/nodes-base/nodes/Strava/GenericFunctions.ts b/packages/nodes-base/nodes/Strava/GenericFunctions.ts index 0ce16aa3c7..f43ceb272e 100644 --- a/packages/nodes-base/nodes/Strava/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strava/GenericFunctions.ts @@ -50,7 +50,7 @@ export async function stravaApiRequest( body.client_secret = credentials.clientSecret; } //@ts-ignore - return this.helpers?.request(options); + return await this.helpers?.request(options); } else { //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'stravaOAuth2Api', options, { diff --git a/packages/nodes-base/nodes/Strava/Strava.node.ts b/packages/nodes-base/nodes/Strava/Strava.node.ts index 3f0c0f59a2..40dfe42ade 100644 --- a/packages/nodes-base/nodes/Strava/Strava.node.ts +++ b/packages/nodes-base/nodes/Strava/Strava.node.ts @@ -113,7 +113,7 @@ export class Strava implements INodeType { `/activities/${activityId}/${path[operation]}`, ); - if (returnAll === false) { + if (!returnAll) { const limit = this.getNodeParameter('limit', i); responseData = responseData.splice(0, limit); } diff --git a/packages/nodes-base/nodes/Strava/StravaTrigger.node.ts b/packages/nodes-base/nodes/Strava/StravaTrigger.node.ts index cf34431716..f7d7887e70 100644 --- a/packages/nodes-base/nodes/Strava/StravaTrigger.node.ts +++ b/packages/nodes-base/nodes/Strava/StravaTrigger.node.ts @@ -143,7 +143,7 @@ export class StravaTrigger implements INodeType { const body = { callback_url: webhookUrl, - verify_token: randomBytes(20).toString('hex') as string, + verify_token: randomBytes(20).toString('hex'), }; let responseData; @@ -174,16 +174,16 @@ export class StravaTrigger implements INodeType { `/push_subscriptions/${webhooks[0].id}`, ); // now there is room create a subscription with the n8n data - const body = { + const requestBody = { callback_url: webhookUrl, - verify_token: randomBytes(20).toString('hex') as string, + verify_token: randomBytes(20).toString('hex'), }; responseData = await stravaApiRequest.call( this, 'POST', `/push_subscriptions`, - body, + requestBody, ); } else { error.message = `A subscription already exists [${webhooks[0].callback_url}]. If you want to delete this subcription and create a new one with the current parameters please go to options and set delete if exist to true`; @@ -227,7 +227,7 @@ export class StravaTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const body = this.getBodyData() as IDataObject; + const body = this.getBodyData(); const query = this.getQueryData() as IDataObject; const object = this.getNodeParameter('object'); const event = this.getNodeParameter('event'); diff --git a/packages/nodes-base/nodes/Stripe/Stripe.node.ts b/packages/nodes-base/nodes/Stripe/Stripe.node.ts index bd04b18472..2d76912239 100644 --- a/packages/nodes-base/nodes/Stripe/Stripe.node.ts +++ b/packages/nodes-base/nodes/Stripe/Stripe.node.ts @@ -114,7 +114,7 @@ export class Stripe implements INodeType { methods = { loadOptions: { async getCustomers(this: ILoadOptionsFunctions) { - return await loadResource.call(this, 'customer'); + return loadResource.call(this, 'customer'); }, async getCurrencies(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; diff --git a/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts b/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts index 04f267f9e1..4d90f4f1a2 100644 --- a/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts +++ b/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts @@ -1,13 +1,7 @@ /* eslint-disable n8n-nodes-base/node-param-description-excess-final-period */ import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, - NodeApiError, -} from 'n8n-workflow'; +import { INodeType, INodeTypeDescription, IWebhookResponseData, NodeApiError } from 'n8n-workflow'; import { stripeApiRequest } from './helpers'; @@ -920,7 +914,7 @@ export class StripeTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const bodyData = this.getBodyData() as IDataObject; + const bodyData = this.getBodyData(); const req = this.getRequestObject(); const events = this.getNodeParameter('events', []) as string[]; diff --git a/packages/nodes-base/nodes/Stripe/helpers.ts b/packages/nodes-base/nodes/Stripe/helpers.ts index 05a1569463..e1a9af4114 100644 --- a/packages/nodes-base/nodes/Stripe/helpers.ts +++ b/packages/nodes-base/nodes/Stripe/helpers.ts @@ -119,7 +119,7 @@ export async function handleListing( let responseData; const returnAll = this.getNodeParameter('returnAll', i); - const limit = this.getNodeParameter('limit', i, 0) as number; + const limit = this.getNodeParameter('limit', i, 0); do { responseData = await stripeApiRequest.call(this, 'GET', `/${resource}s`, {}, qs); diff --git a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts index 34b98f739a..7ecda2fa2a 100644 --- a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts @@ -247,7 +247,7 @@ export function getFilters( ], }, ], - description: `Filter to decide which rows get ${mapOperations[operations[0] as string]}`, + description: `Filter to decide which rows get ${mapOperations[operations[0]]}`, }, { displayName: diff --git a/packages/nodes-base/nodes/Supabase/Supabase.node.ts b/packages/nodes-base/nodes/Supabase/Supabase.node.ts index abeeb7dda3..dfe86b0729 100644 --- a/packages/nodes-base/nodes/Supabase/Supabase.node.ts +++ b/packages/nodes-base/nodes/Supabase/Supabase.node.ts @@ -272,7 +272,7 @@ export class Supabase implements INodeType { endpoint = `${endpoint}?${encodeURI(filterString)}`; } - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', 0); } diff --git a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts index 9c33f09d22..9d4133cd96 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts @@ -41,11 +41,11 @@ export async function surveyMonkeyApiRequest( if (authenticationMethod === 'accessToken') { const credentials = await this.getCredentials('surveyMonkeyApi'); // @ts-ignore - options.headers['Authorization'] = `bearer ${credentials.accessToken}`; + options.headers.Authorization = `bearer ${credentials.accessToken}`; - return await this.helpers.request!(options); + return this.helpers.request!(options); } else { - return await this.helpers.requestOAuth2?.call(this, 'surveyMonkeyOAuth2Api', options); + return this.helpers.requestOAuth2?.call(this, 'surveyMonkeyOAuth2Api', options); } } catch (error) { throw new NodeApiError(this.getNode(), error); diff --git a/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts b/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts index 5074cbc9ca..5d3ca8cd7a 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts @@ -395,7 +395,7 @@ export class SurveyMonkeyTrigger implements INodeType { ); if ( webhookDetails.subscription_url === webhookUrl && - idsExist(webhookDetails.object_ids as string[], ids as string[]) && + idsExist(webhookDetails.object_ids as string[], ids) && webhookDetails.event_type === event ) { // Set webhook-id to be sure that it can be deleted @@ -574,7 +574,7 @@ export class SurveyMonkeyTrigger implements INodeType { responseQuestions.set(heading, answers.get(question.id)![0].text as string); } else { const results: IDataObject = {}; - const keys = (question.answers.rows as IRow[]).map((e) => e.text) as string[]; + const keys = (question.answers.rows as IRow[]).map((e) => e.text); const values = answers.get(question.id)?.map((e) => e.text) as string[]; for (let i = 0; i < keys.length; i++) { // if for some reason there are questions texts repeted add the index to the key @@ -591,13 +591,12 @@ export class SurveyMonkeyTrigger implements INodeType { if (question.family === 'single_choice') { const other = question.answers.other as IOther; if ( - other && - other.visible && + other?.visible && other.is_answer_choice && answers.get(question.id)![0].other_id ) { responseQuestions.set(heading, answers.get(question.id)![0].text as string); - } else if (other && other.visible && !other.is_answer_choice) { + } else if (other?.visible && !other.is_answer_choice) { const choiceId = answers.get(question.id)![0].choice_id; const choice = (question.answers.choices as IChoice[]).filter( @@ -621,9 +620,9 @@ export class SurveyMonkeyTrigger implements INodeType { const choiceIds = answers.get(question.id)?.map((e) => e.choice_id); const value = (question.answers.choices as IChoice[]) .filter((e) => choiceIds?.includes(e.id)) - .map((e) => e.text) as string[]; + .map((e) => e.text); // if "Add an "Other" Answer Option for Comments" is active and was selected - if (other && other.is_answer_choice && other.visible) { + if (other?.is_answer_choice && other.visible) { const text = answers.get(question.id)?.find((e) => e.other_id === other.id) ?.text as string; value.push(text); @@ -641,11 +640,11 @@ export class SurveyMonkeyTrigger implements INodeType { const rowIds = answers.get(question.id)?.map((e) => e.row_id) as string[]; const rowsValues = (question.answers.rows as IRow[]) - .filter((e) => rowIds!.includes(e.id as string)) + .filter((e) => rowIds.includes(e.id)) .map((e) => e.text); const choicesValues = (question.answers.choices as IChoice[]) - .filter((e) => choiceIds!.includes(e.id as string)) + .filter((e) => choiceIds.includes(e.id)) .map((e) => e.text); for (let i = 0; i < rowsValues.length; i++) { @@ -660,7 +659,7 @@ export class SurveyMonkeyTrigger implements INodeType { } // the comment then add the comment const other = question.answers.other as IOther; - if (other !== undefined && other.visible) { + if (other?.visible) { results.comment = answers.get(question.id)?.filter((e) => e.other_id)[0].text; } @@ -668,13 +667,13 @@ export class SurveyMonkeyTrigger implements INodeType { } else { const choiceIds = answers.get(question.id)?.map((e) => e.choice_id); const value = (question.answers.choices as IChoice[]) - .filter((e) => choiceIds!.includes(e.id as string)) + .filter((e) => choiceIds!.includes(e.id)) .map((e) => (e.text === '' ? e.weight : e.text))[0]; responseQuestions.set(heading, value); // if "Add an Other Answer Option for Comments" is active then add comment to the answer const other = question.answers.other as IOther; - if (other !== undefined && other.visible) { + if (other?.visible) { const response: IDataObject = {}; //const questionName = (question.answers.other as IOther).text as string; const text = answers.get(question.id)?.filter((e) => e.other_id)[0].text; diff --git a/packages/nodes-base/nodes/Switch/Switch.node.ts b/packages/nodes-base/nodes/Switch/Switch.node.ts index db6e176367..9d29647adc 100644 --- a/packages/nodes-base/nodes/Switch/Switch.node.ts +++ b/packages/nodes-base/nodes/Switch/Switch.node.ts @@ -526,7 +526,6 @@ export class Switch implements INodeType { let mode: string; let outputIndex: number; let ruleData: INodeParameters; - let value1: NodeParameterValue, value2: NodeParameterValue; // The compare operations const compareOperationFunctions: { @@ -637,7 +636,7 @@ export class Switch implements INodeType { const dataType = this.getNodeParameter('dataType', 0) as string; - value1 = this.getNodeParameter('value1', itemIndex) as NodeParameterValue; + let value1 = this.getNodeParameter('value1', itemIndex) as NodeParameterValue; if (dataType === 'dateTime') { value1 = convertDateTime(value1); } @@ -649,7 +648,7 @@ export class Switch implements INodeType { ) as INodeParameters[]) { // Check if the values passes - value2 = ruleData.value2 as NodeParameterValue; + let value2 = ruleData.value2 as NodeParameterValue; if (dataType === 'dateTime') { value2 = convertDateTime(value2); } @@ -659,7 +658,7 @@ export class Switch implements INodeType { value2, ); - if (compareOperationResult === true) { + if (compareOperationResult) { // If rule matches add it to the correct output and continue with next item checkIndexRange(ruleData.output as number); returnData[ruleData.output as number].push(item); diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/SyncroMspV1.node.ts b/packages/nodes-base/nodes/SyncroMSP/v1/SyncroMspV1.node.ts index f5c139ec91..f765471475 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/SyncroMspV1.node.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/SyncroMspV1.node.ts @@ -52,6 +52,6 @@ export class SyncroMspV1 implements INodeType { }; async execute(this: IExecuteFunctions) { - return await router.call(this); + return router.call(this); } } 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 b4a36f73a1..1d5f535036 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 @@ -10,10 +10,7 @@ export async function createContact( ): Promise { const id = this.getNodeParameter('customerId', index) as IDataObject; const email = this.getNodeParameter('email', index) as IDataObject; - const { address, notes, phone, name } = this.getNodeParameter( - 'additionalFields', - index, - ) as IDataObject; + const { address, notes, phone, name } = this.getNodeParameter('additionalFields', index); const qs = {} as IDataObject; const requestMethod = 'POST'; @@ -22,7 +19,7 @@ export async function createContact( let addressData = address as IDataObject; if (addressData) { - addressData = addressData['addressFields'] as IDataObject; + addressData = addressData.addressFields as IDataObject; addressData.address1 = addressData.address; } @@ -35,8 +32,7 @@ export async function createContact( phone, }; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); } 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 935270004e..6438747628 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 @@ -15,7 +15,6 @@ export async function deleteContact( const endpoint = `contacts/${id}`; const body = {} as IDataObject; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); } 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 5c0688d367..7d41cb724f 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 @@ -15,7 +15,6 @@ export async function getContact( const endpoint = `contacts/${id}`; const body = {} as IDataObject; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); } 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 8c92939052..d10c49a1ac 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 @@ -8,7 +8,7 @@ export async function getAll( this: IExecuteFunctions, index: number, ): Promise { - const returnAll = this.getNodeParameter('returnAll', index) as boolean; + const returnAll = this.getNodeParameter('returnAll', index); const qs = {} as IDataObject; const requestMethod = 'GET'; 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 3514f8be9b..08b22b945f 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 @@ -12,7 +12,7 @@ export async function updateContact( const { address, customerId, email, name, notes, phone } = this.getNodeParameter( 'updateFields', index, - ) as IDataObject; + ); const qs = {} as IDataObject; const requestMethod = 'PUT'; @@ -21,7 +21,7 @@ export async function updateContact( let addressData = address as IDataObject; if (addressData) { - addressData = addressData['addressFields'] as IDataObject; + addressData = addressData.addressFields as IDataObject; addressData.address1 = addressData.address; } @@ -35,8 +35,7 @@ export async function updateContact( phone, }; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); } 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 eb72512772..3c3c1e0367 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 @@ -30,7 +30,7 @@ export async function addCustomer( let addressData = address as IDataObject; if (addressData) { - addressData = addressData['addressFields'] as IDataObject; + addressData = addressData.addressFields as IDataObject; addressData.address_2 = addressData.address2; } @@ -49,8 +49,7 @@ export async function addCustomer( referred_by: referredBy, }; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.customer); } 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 80d02e3eff..bada284b13 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 @@ -15,7 +15,6 @@ export async function deleteCustomer( const endpoint = `customers/${id}`; const body = {} as IDataObject; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); } 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 150901c698..64de3d7075 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 @@ -15,7 +15,6 @@ export async function getCustomer( const endpoint = `customers/${id}`; const body = {} as IDataObject; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.customer); } 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 8f0cc4399b..3baaabff66 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 @@ -8,7 +8,7 @@ export async function getAll( this: IExecuteFunctions, index: number, ): Promise { - const returnAll = this.getNodeParameter('returnAll', index) as boolean; + const returnAll = this.getNodeParameter('returnAll', index); const filters = this.getNodeParameter('filters', index); let qs = {} as IDataObject; @@ -26,7 +26,7 @@ export async function getAll( } } - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', index); } 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 ddd6887e66..0ff127fdc1 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 @@ -22,7 +22,7 @@ export async function updateCustomer( notificationEmail, phone, referredBy, - } = this.getNodeParameter('updateFields', index) as IDataObject; + } = this.getNodeParameter('updateFields', index); const qs = {} as IDataObject; const requestMethod = 'PUT'; @@ -31,7 +31,7 @@ export async function updateCustomer( let addressData = address as IDataObject; if (addressData) { - addressData = addressData['addressFields'] as IDataObject; + addressData = addressData.addressFields as IDataObject; addressData.address_2 = addressData.address2; } @@ -50,8 +50,7 @@ export async function updateCustomer( referred_by: referredBy, }; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); if (!responseData.customer) { throw new NodeApiError(this.getNode(), responseData, { httpCode: '404', 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 d6f7aa0618..87c520723a 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 @@ -26,8 +26,7 @@ export async function addAlert( body.asset_id = assetId; body.description = description; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.alert); } 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 7647eab89f..3e359252f1 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 @@ -15,7 +15,6 @@ export async function deleteAlert( const endpoint = `rmm_alerts/${id}`; const body = {} as IDataObject; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); } 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 5c8ccec151..794f188e97 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 @@ -15,7 +15,6 @@ export async function getAlert( const endpoint = `rmm_alerts/${id}`; const body = {} as IDataObject; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.rmm_alert); } 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 fdad9f37c0..3411177757 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 @@ -8,7 +8,7 @@ export async function getAll( this: IExecuteFunctions, index: number, ): Promise { - const returnAll = this.getNodeParameter('returnAll', index) as boolean; + const returnAll = this.getNodeParameter('returnAll', index); const filters = this.getNodeParameter('filters', index); let qs = {} as IDataObject; @@ -24,7 +24,7 @@ export async function getAll( qs.status = 'all'; } - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', index); } 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 4195529221..5df2087232 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 @@ -19,7 +19,6 @@ export async function muteAlert( body.id = id; body.mute_for = mute; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/execute.ts index 43a33f6858..9e3b8f2ae3 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/execute.ts @@ -13,7 +13,7 @@ export async function createTicket( const { assetId, issueType, status, contactId } = this.getNodeParameter( 'additionalFields', index, - ) as IDataObject; + ); const qs = {} as IDataObject; const requestMethod = 'POST'; @@ -31,9 +31,7 @@ export async function createTicket( body.customer_id = id; body.subject = subject; - let responseData; - - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.ticket); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/execute.ts index d7935a270e..a6c483bcd0 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/execute.ts @@ -15,7 +15,6 @@ export async function deleteTicket( const endpoint = `tickets/${id}`; const body = {} as IDataObject; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/execute.ts index e9264f70b0..c68fcd475a 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/execute.ts @@ -15,7 +15,6 @@ export async function getTicket( const endpoint = `tickets/${id}`; const body = {} as IDataObject; - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.ticket); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/execute.ts index 10b2203ab3..717a4020c3 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/execute.ts @@ -8,7 +8,7 @@ export async function getAll( this: IExecuteFunctions, index: number, ): Promise { - const returnAll = this.getNodeParameter('returnAll', index) as boolean; + const returnAll = this.getNodeParameter('returnAll', index); const filters = this.getNodeParameter('filters', index); let qs = {} as IDataObject; @@ -20,7 +20,7 @@ export async function getAll( qs = filters; } - if (returnAll === false) { + if (!returnAll) { qs.per_page = this.getNodeParameter('limit', index); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/execute.ts index 85a5dec98c..fcbe395775 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/execute.ts @@ -10,7 +10,7 @@ export async function updateTicket( ): Promise { const id = this.getNodeParameter('ticketId', index) as IDataObject; const { assetId, customerId, dueDate, issueType, status, subject, ticketType, contactId } = - this.getNodeParameter('updateFields', index) as IDataObject; + this.getNodeParameter('updateFields', index); const qs = {} as IDataObject; const requestMethod = 'PUT'; @@ -34,8 +34,7 @@ export async function updateTicket( }); } - let responseData; - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.ticket); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/transport/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/transport/index.ts index cf6ede6bbd..be533caaf5 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/transport/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/transport/index.ts @@ -21,7 +21,7 @@ export async function apiRequest( ) { const credentials = await this.getCredentials('syncroMspApi'); - query['api_key'] = credentials.apiKey; + query.api_key = credentials.apiKey; const options: IHttpRequestOptions = { method, diff --git a/packages/nodes-base/nodes/Taiga/GenericFunctions.ts b/packages/nodes-base/nodes/Taiga/GenericFunctions.ts index a6f999514b..9b0139920e 100644 --- a/packages/nodes-base/nodes/Taiga/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Taiga/GenericFunctions.ts @@ -137,8 +137,8 @@ export async function handleListing( this: IExecuteFunctions, method: string, endpoint: string, - body: IDataObject = {}, - qs: IDataObject = {}, + body: IDataObject, + qs: IDataObject, i: number, ) { let responseData; @@ -146,7 +146,7 @@ export async function handleListing( const returnAll = this.getNodeParameter('returnAll', i); if (returnAll) { - return await taigaApiRequestAllItems.call(this, method, endpoint, body, qs); + return taigaApiRequestAllItems.call(this, method, endpoint, body, qs); } else { qs.limit = this.getNodeParameter('limit', i); responseData = await taigaApiRequestAllItems.call(this, method, endpoint, body, qs); @@ -165,5 +165,5 @@ export function throwOnEmptyUpdate(this: IExecuteFunctions, resource: Resource) } export async function getVersionForUpdate(this: IExecuteFunctions, endpoint: string) { - return await taigaApiRequest.call(this, 'GET', endpoint).then((response) => response.version); + return taigaApiRequest.call(this, 'GET', endpoint).then((response) => response.version); } diff --git a/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts b/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts index 65703b12f2..262e9b088c 100644 --- a/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts +++ b/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts @@ -177,8 +177,8 @@ export class Tapfiliate implements INodeType { //https://tapfiliate.com/docs/rest/#affiliates-meta-data-key-put const affiliateId = this.getNodeParameter('affiliateId', i) as string; const metadata = - (((this.getNodeParameter('metadataUi', i) as IDataObject) || {}) - .metadataValues as IDataObject[]) || []; + ((this.getNodeParameter('metadataUi', i) as IDataObject) + ?.metadataValues as IDataObject[]) || []; if (metadata.length === 0) { throw new NodeOperationError(this.getNode(), 'Metadata cannot be empty.', { itemIndex: i, diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index fe00302990..e15a9ad4f5 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IDataObject, INodeExecutionData, INodeType, @@ -1829,10 +1828,7 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.message_id = this.getNodeParameter('messageId', i) as string; - const { disable_notification } = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const { disable_notification } = this.getNodeParameter('additionalFields', i); if (disable_notification) { body.disable_notification = true; } @@ -1981,16 +1977,16 @@ export class Telegram implements INodeType { let responseData; - if (binaryData === true) { + if (binaryData) { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; - const binaryData = items[i].binary![binaryPropertyName] as IBinaryData; + const itemBinaryData = items[i].binary![binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); const propertyName = getPropertyName(operation); const fileName = this.getNodeParameter('additionalFields.fileName', 0, '') as string; - const filename = fileName || binaryData.fileName?.toString(); + const filename = fileName || itemBinaryData.fileName?.toString(); - if (!fileName && !binaryData.fileName) { + if (!fileName && !itemBinaryData.fileName) { throw new NodeOperationError( this.getNode(), `File name is needed to ${operation}. Make sure the property that holds the binary data @@ -2007,7 +2003,7 @@ export class Telegram implements INodeType { value: dataBuffer, options: { filename, - contentType: binaryData.mimeType, + contentType: itemBinaryData.mimeType, }, }, }; @@ -2018,7 +2014,7 @@ export class Telegram implements INodeType { } if (resource === 'file' && operation === 'get') { - if (this.getNodeParameter('download', i, false) === true) { + if (this.getNodeParameter('download', i, false)) { const filePath = responseData.result.file_path; const credentials = await this.getCredentials('telegramApi'); @@ -2037,7 +2033,7 @@ export class Telegram implements INodeType { ); const fileName = filePath.split('/').pop(); - const binaryData = await this.helpers.prepareBinaryData( + const data = await this.helpers.prepareBinaryData( Buffer.from(file.body as string), fileName, ); @@ -2045,7 +2041,7 @@ export class Telegram implements INodeType { returnData.push({ json: responseData, binary: { - data: binaryData, + data, }, pairedItem: { item: i }, }); diff --git a/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts b/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts index 9cfd7f43fc..655effba7d 100644 --- a/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts +++ b/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts @@ -225,7 +225,7 @@ export class TelegramTrigger implements INodeType { } if ( - (bodyData[key] && bodyData[key]?.photo && Array.isArray(bodyData[key]?.photo)) || + (bodyData[key]?.photo && Array.isArray(bodyData[key]?.photo)) || bodyData[key]?.document ) { if (additionalFields.imageSize) { diff --git a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts index b7bb38e3ff..ea7e78ab7d 100644 --- a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts @@ -24,7 +24,7 @@ export async function theHiveApiRequest( qs: query, uri: uri || `${credentials.url}/api${resource}`, body, - rejectUnauthorized: !credentials.allowUnauthorizedCerts as boolean, + rejectUnauthorized: !credentials.allowUnauthorizedCerts, json: true, }; @@ -94,7 +94,7 @@ export async function prepareCustomFields( jsonParameters = false, ): Promise { // Check if the additionalFields object contains customFields - if (jsonParameters === true) { + if (jsonParameters) { let customFieldsJson = additionalFields.customFieldsJson; // Delete from additionalFields as some operations (e.g. alert:update) do not run prepareOptional // which would remove the extra fields @@ -181,9 +181,9 @@ export function prepareSortQuery(sort: string, body: { query: [IDataObject] }) { } } -export function prepareRangeQuery(range: string, body: { query: Array<{}> }) { +export function prepareRangeQuery(range: string, body: { query: IDataObject[] }) { if (range && range !== 'all') { - body['query'].push({ + body.query.push({ _name: 'page', from: parseInt(range.split('-')[0], 10), to: parseInt(range.split('-')[1], 10), diff --git a/packages/nodes-base/nodes/TheHive/QueryFunctions.ts b/packages/nodes-base/nodes/TheHive/QueryFunctions.ts index 09c79d87f2..7bb5a4f604 100644 --- a/packages/nodes-base/nodes/TheHive/QueryFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/QueryFunctions.ts @@ -80,8 +80,8 @@ export function Child(tpe: string, criterion: IQueryObject): IQueryObject { export function Type(tpe: string): IQueryObject { return { _type: tpe }; } -export function queryString(queryString: string): IQueryObject { - return { _string: queryString }; +export function queryString(query: string): IQueryObject { + return { _string: query }; } export function Like(field: string, value: string): IQueryObject { return { _like: { _field: field, _value: value } }; diff --git a/packages/nodes-base/nodes/TheHive/TheHive.node.ts b/packages/nodes-base/nodes/TheHive/TheHive.node.ts index d974dd3563..5da6597137 100644 --- a/packages/nodes-base/nodes/TheHive/TheHive.node.ts +++ b/packages/nodes-base/nodes/TheHive/TheHive.node.ts @@ -1,7 +1,7 @@ +/* eslint-disable @typescript-eslint/dot-notation */ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IDataObject, ILoadOptionsFunctions, INodeExecutionData, @@ -105,6 +105,7 @@ export class TheHive implements INodeType { ...logFields, ], }; + methods = { loadOptions: { async loadResponders(this: ILoadOptionsFunctions): Promise { @@ -113,7 +114,7 @@ export class TheHive implements INodeType { const resourceId = this.getNodeParameter('id'); const endpoint = `/connector/cortex/responder/${resource}/${resourceId}`; - const responders = await theHiveApiRequest.call(this, 'GET', endpoint as string); + const responders = await theHiveApiRequest.call(this, 'GET', endpoint); const returnData: INodePropertyOptions[] = []; @@ -131,7 +132,7 @@ export class TheHive implements INodeType { // request the analyzers from instance const dataType = this.getNodeParameter('dataType') as string; const endpoint = `/connector/cortex/analyzer/type/${dataType}`; - const requestResult = await theHiveApiRequest.call(this, 'GET', endpoint as string); + const requestResult = await theHiveApiRequest.call(this, 'GET', endpoint); const returnData: INodePropertyOptions[] = []; for (const analyzer of requestResult) { @@ -408,7 +409,7 @@ export class TheHive implements INodeType { const artifactUi = this.getNodeParameter('artifactUi', i) as IDataObject; if (artifactUi) { - const artifactValues = (artifactUi as IDataObject).artifactValues as IDataObject[]; + const artifactValues = artifactUi.artifactValues as IDataObject[]; if (artifactValues) { const artifactData = []; @@ -418,7 +419,7 @@ export class TheHive implements INodeType { element.message = artifactvalue.message as string; - element.tags = (artifactvalue.tags as string).split(',') as string[]; + element.tags = (artifactvalue.tags as string).split(','); element.dataType = artifactvalue.dataType as string; @@ -445,7 +446,7 @@ export class TheHive implements INodeType { ); } - const binaryData = item.binary[binaryPropertyName] as IBinaryData; + const binaryData = item.binary[binaryPropertyName]; element.data = `${binaryData.fileName};${binaryData.mimeType};${binaryData.data}`; } @@ -520,7 +521,6 @@ export class TheHive implements INodeType { i, false, ) as boolean; - const qs: IDataObject = {}; if (includeSimilar) { qs.similarity = true; @@ -571,7 +571,7 @@ export class TheHive implements INodeType { let limit = undefined; - if (returnAll === false) { + if (!returnAll) { limit = this.getNodeParameter('limit', i); } @@ -615,7 +615,7 @@ export class TheHive implements INodeType { Object.assign(qs, prepareOptional(options)); } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'markAsRead') { @@ -686,7 +686,7 @@ export class TheHive implements INodeType { Object.assign(body, updateFields); if (artifactUi) { - const artifactValues = (artifactUi as IDataObject).artifactValues as IDataObject[]; + const artifactValues = artifactUi.artifactValues as IDataObject[]; if (artifactValues) { const artifactData = []; @@ -696,7 +696,7 @@ export class TheHive implements INodeType { element.message = artifactvalue.message as string; - element.tags = (artifactvalue.tags as string).split(',') as string[]; + element.tags = (artifactvalue.tags as string).split(','); element.dataType = artifactvalue.dataType as string; @@ -723,7 +723,7 @@ export class TheHive implements INodeType { ); } - const binaryData = item.binary[binaryPropertyName] as IBinaryData; + const binaryData = item.binary[binaryPropertyName]; element.data = `${binaryData.fileName};${binaryData.mimeType};${binaryData.data}`; } @@ -734,12 +734,7 @@ export class TheHive implements INodeType { } } - responseData = await theHiveApiRequest.call( - this, - 'PATCH', - `/alert/${alertId}` as string, - body, - ); + responseData = await theHiveApiRequest.call(this, 'PATCH', `/alert/${alertId}`, body); } } @@ -923,7 +918,7 @@ export class TheHive implements INodeType { ); } - const binaryData = item.binary[binaryPropertyName] as IBinaryData; + const binaryData = item.binary[binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); options = { @@ -946,7 +941,7 @@ export class TheHive implements INodeType { responseData = await theHiveApiRequest.call( this, 'POST', - `/case/${caseId}/artifact` as string, + `/case/${caseId}/artifact`, body, qs, '', @@ -988,7 +983,7 @@ export class TheHive implements INodeType { endpoint = `/case/artifact/${observableId}`; } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'getAll') { @@ -1010,7 +1005,7 @@ export class TheHive implements INodeType { let limit = undefined; - if (returnAll === false) { + if (!returnAll) { limit = this.getNodeParameter('limit', i); } @@ -1054,7 +1049,7 @@ export class TheHive implements INodeType { Object.assign(qs, prepareOptional(options)); } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'search') { @@ -1104,7 +1099,7 @@ export class TheHive implements INodeType { let limit = undefined; - if (returnAll === false) { + if (!returnAll) { limit = this.getNodeParameter('limit', i); } @@ -1148,7 +1143,7 @@ export class TheHive implements INodeType { Object.assign(qs, prepareOptional(options)); } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'update') { @@ -1161,7 +1156,7 @@ export class TheHive implements INodeType { responseData = await theHiveApiRequest.call( this, 'PATCH', - `/case/artifact/${id}` as string, + `/case/artifact/${id}`, body, qs, ); @@ -1331,7 +1326,7 @@ export class TheHive implements INodeType { endpoint = `/case/${caseId}`; } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'getAll') { @@ -1378,7 +1373,7 @@ export class TheHive implements INodeType { let limit = undefined; - if (returnAll === false) { + if (!returnAll) { limit = this.getNodeParameter('limit', i); } @@ -1422,7 +1417,7 @@ export class TheHive implements INodeType { Object.assign(qs, prepareOptional(options)); } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'update') { @@ -1437,12 +1432,7 @@ export class TheHive implements INodeType { ...prepareOptional(updateFields), }; - responseData = await theHiveApiRequest.call( - this, - 'PATCH', - `/case/${id}` as string, - body, - ); + responseData = await theHiveApiRequest.call(this, 'PATCH', `/case/${id}`, body); } } @@ -1499,12 +1489,7 @@ export class TheHive implements INodeType { ...prepareOptional(this.getNodeParameter('options', i, {}) as INodeParameters), }; - responseData = await theHiveApiRequest.call( - this, - 'POST', - `/case/${caseId}/task` as string, - body, - ); + responseData = await theHiveApiRequest.call(this, 'POST', `/case/${caseId}/task`, body); } if (operation === 'executeResponder') { @@ -1590,7 +1575,7 @@ export class TheHive implements INodeType { endpoint = `/case/task/${taskId}`; } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'getAll') { @@ -1613,7 +1598,7 @@ export class TheHive implements INodeType { let limit = undefined; - if (returnAll === false) { + if (!returnAll) { limit = this.getNodeParameter('limit', i); } @@ -1657,7 +1642,7 @@ export class TheHive implements INodeType { Object.assign(qs, prepareOptional(options)); } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'search') { @@ -1695,7 +1680,7 @@ export class TheHive implements INodeType { let limit = undefined; - if (returnAll === false) { + if (!returnAll) { limit = this.getNodeParameter('limit', i); } @@ -1739,7 +1724,7 @@ export class TheHive implements INodeType { Object.assign(qs, prepareOptional(options)); } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'update') { @@ -1749,12 +1734,7 @@ export class TheHive implements INodeType { ...prepareOptional(this.getNodeParameter('updateFields', i, {}) as INodeParameters), }; - responseData = await theHiveApiRequest.call( - this, - 'PATCH', - `/case/task/${id}` as string, - body, - ); + responseData = await theHiveApiRequest.call(this, 'PATCH', `/case/task/${id}`, body); } } @@ -1794,7 +1774,7 @@ export class TheHive implements INodeType { ); } - const binaryData = item.binary[binaryPropertyName] as IBinaryData; + const binaryData = item.binary[binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); options = { @@ -1817,7 +1797,7 @@ export class TheHive implements INodeType { responseData = await theHiveApiRequest.call( this, 'POST', - `/case/task/${taskId}/log` as string, + `/case/task/${taskId}/log`, body, qs, '', @@ -1910,7 +1890,7 @@ export class TheHive implements INodeType { body.query = { _id: logId }; } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'getAll') { @@ -1930,7 +1910,7 @@ export class TheHive implements INodeType { let limit = undefined; - if (returnAll === false) { + if (!returnAll) { limit = this.getNodeParameter('limit', i); } @@ -1969,7 +1949,7 @@ export class TheHive implements INodeType { body.query = And(Parent('task', Id(taskId))); } - responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); + responseData = await theHiveApiRequest.call(this, method, endpoint, body, qs); } } diff --git a/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts b/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts index 7100cf5fcf..a16b35f58b 100644 --- a/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts +++ b/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts @@ -32,6 +32,7 @@ export class TheHiveTrigger implements INodeType { ], properties: [...eventsDescription], }; + // @ts-ignore (because of request) webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts b/packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts index b1472297d8..d7a5ad166d 100644 --- a/packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts +++ b/packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts @@ -322,7 +322,7 @@ export class TimescaleDb implements INodeType { returnItems = this.helpers.returnJsonArray(updateItems); } else { - await pgp.end(); + pgp.end(); throw new NodeOperationError( this.getNode(), `The operation "${operation}" is not supported!`, @@ -330,7 +330,7 @@ export class TimescaleDb implements INodeType { } // Close the connection - await pgp.end(); + pgp.end(); return this.prepareOutputData(returnItems); } diff --git a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts index f76ca49e00..ee670a8da7 100644 --- a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts @@ -260,7 +260,7 @@ export class SyncHandler implements OperationHandler { private convertToObject(map: Map) { return Array.from(map.entries()).reduce((o, [key, value]) => { - o[key as string] = value; + o[key] = value; return o; }, {} as IDataObject); } @@ -270,7 +270,7 @@ export class SyncHandler implements OperationHandler { } private enrichSection(command: Command, sections: Map) { - if (command.args !== undefined && command.args.section !== undefined) { + if (command.args?.section !== undefined) { const sectionId = sections.get(command.args.section); if (sectionId) { command.args.section_id = sectionId; @@ -292,7 +292,7 @@ export class SyncHandler implements OperationHandler { private enrichTempId(command: Command, tempIdMapping: Map, projectId: number) { if (this.requiresTempId(command)) { - command.temp_id = uuid() as string; + command.temp_id = uuid(); tempIdMapping.set(command.temp_id, projectId as unknown as string); } } @@ -328,7 +328,7 @@ export interface CreateTaskRequest { export interface SyncRequest { commands: Command[]; - temp_id_mapping?: {}; + temp_id_mapping?: IDataObject; } export interface Command { diff --git a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts index 4efe237e99..01ac5cdc60 100644 --- a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts @@ -270,7 +270,7 @@ export class SyncHandler implements OperationHandler { } private enrichSection(command: Command, sections: Map) { - if (command.args !== undefined && command.args.section !== undefined) { + if (command.args?.section !== undefined) { const sectionId = sections.get(command.args.section); if (sectionId) { command.args.section_id = sectionId; @@ -292,7 +292,7 @@ export class SyncHandler implements OperationHandler { private enrichTempId(command: Command, tempIdMapping: Map, projectId: number) { if (this.requiresTempId(command)) { - command.temp_id = uuid() as string; + command.temp_id = uuid(); tempIdMapping.set(command.temp_id, projectId as unknown as string); } } @@ -319,7 +319,7 @@ export interface CreateTaskRequest { export interface SyncRequest { commands: Command[]; - temp_id_mapping?: {}; + temp_id_mapping?: IDataObject; } export interface Command { diff --git a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts index de6fad8c46..ba3711f201 100644 --- a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts @@ -71,6 +71,6 @@ export async function travisciApiRequestAllItems( query = Object.fromEntries(parsedPath); } returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData['@pagination']['is_last'] !== true); + } 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 6a3f0bb6f2..bf4ae66061 100644 --- a/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts +++ b/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts @@ -86,7 +86,7 @@ export class TravisCi implements INodeType { qs.include = additionalFields.include; } - if (returnAll === true) { + if (returnAll) { responseData = await travisciApiRequestAllItems.call( this, 'builds', diff --git a/packages/nodes-base/nodes/Trello/Trello.node.ts b/packages/nodes-base/nodes/Trello/Trello.node.ts index 7c6f166e5c..7dedc4ceae 100644 --- a/packages/nodes-base/nodes/Trello/Trello.node.ts +++ b/packages/nodes-base/nodes/Trello/Trello.node.ts @@ -283,7 +283,7 @@ export class Trello implements INodeType { const id = this.getNodeParameter('id', i) as string; returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -499,7 +499,7 @@ export class Trello implements INodeType { returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -518,7 +518,7 @@ export class Trello implements INodeType { returnAll = this.getNodeParameter('returnAll', i); - if (returnAll === false) { + if (!returnAll) { qs.limit = this.getNodeParameter('limit', i); } @@ -890,11 +890,11 @@ export class Trello implements INodeType { // paginate them 'manually' const skipPagination = ['list:getAll']; - if (returnAll === true && !skipPagination.includes(`${resource}:${operation}`)) { + if (returnAll && !skipPagination.includes(`${resource}:${operation}`)) { responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs); } else { responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - if (returnAll === false && qs.limit) { + if (!returnAll && qs.limit) { responseData = responseData.splice(0, qs.limit); } } diff --git a/packages/nodes-base/nodes/Twilio/Twilio.node.ts b/packages/nodes-base/nodes/Twilio/Twilio.node.ts index 694fbed196..2480cf9156 100644 --- a/packages/nodes-base/nodes/Twilio/Twilio.node.ts +++ b/packages/nodes-base/nodes/Twilio/Twilio.node.ts @@ -222,8 +222,8 @@ export class Twilio implements INodeType { body = {}; qs = {}; - resource = this.getNodeParameter('resource', i) as string; - operation = this.getNodeParameter('operation', i) as string; + resource = this.getNodeParameter('resource', i); + operation = this.getNodeParameter('operation', i); if (resource === 'sms') { if (operation === 'send') { @@ -241,7 +241,7 @@ export class Twilio implements INodeType { const toWhatsapp = this.getNodeParameter('toWhatsapp', i) as boolean; - if (toWhatsapp === true) { + if (toWhatsapp) { body.From = `whatsapp:${body.From}`; body.To = `whatsapp:${body.To}`; } diff --git a/packages/nodes-base/nodes/Twist/Twist.node.ts b/packages/nodes-base/nodes/Twist/Twist.node.ts index f2d054403c..ee98291a0d 100644 --- a/packages/nodes-base/nodes/Twist/Twist.node.ts +++ b/packages/nodes-base/nodes/Twist/Twist.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IBinaryData, IBinaryKeyData, IDataObject, ILoadOptionsFunctions, @@ -250,14 +249,14 @@ export class Twist implements INodeType { } if (body.binaryProperties) { - const binaryProperties = (body.binaryProperties as string).split(',') as string[]; + const binaryProperties = (body.binaryProperties as string).split(','); const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryProperty] as IBinaryData; + const binaryData = item[binaryProperty]; if (binaryData === undefined) { throw new NodeOperationError( @@ -359,14 +358,14 @@ export class Twist implements INodeType { } if (body.binaryProperties) { - const binaryProperties = (body.binaryProperties as string).split(',') as string[]; + const binaryProperties = (body.binaryProperties as string).split(','); const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryProperty] as IBinaryData; + const binaryData = item[binaryProperty]; if (binaryData === undefined) { throw new NodeOperationError( @@ -438,14 +437,14 @@ export class Twist implements INodeType { } if (body.binaryProperties) { - const binaryProperties = (body.binaryProperties as string).split(',') as string[]; + const binaryProperties = (body.binaryProperties as string).split(','); const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryProperty] as IBinaryData; + const binaryData = item[binaryProperty]; if (binaryData === undefined) { throw new NodeOperationError( @@ -563,14 +562,14 @@ export class Twist implements INodeType { } if (body.binaryProperties) { - const binaryProperties = (body.binaryProperties as string).split(',') as string[]; + const binaryProperties = (body.binaryProperties as string).split(','); const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryProperty] as IBinaryData; + const binaryData = item[binaryProperty]; if (binaryData === undefined) { throw new NodeOperationError( @@ -647,14 +646,14 @@ export class Twist implements INodeType { } if (body.binaryProperties) { - const binaryProperties = (body.binaryProperties as string).split(',') as string[]; + const binaryProperties = (body.binaryProperties as string).split(','); const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryProperty] as IBinaryData; + const binaryData = item[binaryProperty]; if (binaryData === undefined) { throw new NodeOperationError( @@ -755,14 +754,14 @@ export class Twist implements INodeType { } if (body.binaryProperties) { - const binaryProperties = (body.binaryProperties as string).split(',') as string[]; + const binaryProperties = (body.binaryProperties as string).split(','); const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { const item = items[i].binary as IBinaryKeyData; - const binaryData = item[binaryProperty] as IBinaryData; + const binaryData = item[binaryProperty]; if (binaryData === undefined) { throw new NodeOperationError( diff --git a/packages/nodes-base/nodes/Twitter/GenericFunctions.ts b/packages/nodes-base/nodes/Twitter/GenericFunctions.ts index 0cd186af21..6efa943dd8 100644 --- a/packages/nodes-base/nodes/Twitter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twitter/GenericFunctions.ts @@ -69,7 +69,7 @@ export async function twitterApiRequestAllItems( responseData = await twitterApiRequest.call(this, method, endpoint, body, query); query.since_id = responseData.search_metadata.max_id; returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData.search_metadata && responseData.search_metadata.next_results); + } while (responseData.search_metadata?.next_results); return returnData; } @@ -128,23 +128,23 @@ export async function uploadAttachments( } if (isImage) { - const attachmentBody = { + const form = { media_data: binaryData[binaryPropertyName].data, }; response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { - form: attachmentBody, + form, }); media.push(response); } else { // https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-init - const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); attachmentBody = { command: 'INIT', - total_bytes: dataBuffer.byteLength, + total_bytes: binaryDataBuffer.byteLength, media_type: binaryData[binaryPropertyName].mimeType, }; @@ -156,7 +156,7 @@ export async function uploadAttachments( // break the data on 5mb chunks (max size that can be uploaded at once) - const binaryParts = chunks(dataBuffer, 5242880); + const binaryParts = chunks(binaryDataBuffer, 5242880); let index = 0; diff --git a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts index 69071d9d11..461c2536e7 100644 --- a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts @@ -1,11 +1,9 @@ import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { INodePropertyOptions, NodeApiError, NodeOperationError } from 'n8n-workflow'; +import { IDataObject, INodePropertyOptions, NodeApiError, NodeOperationError } from 'n8n-workflow'; import { OptionsWithUri } from 'request'; -import { IDataObject } from 'n8n-workflow'; - // Interface in Typeform export interface ITypeformDefinition { fields: ITypeformDefinitionField[]; diff --git a/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts b/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts index acb9c3a650..51601f0d80 100644 --- a/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts +++ b/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts @@ -243,7 +243,7 @@ export class TypeformTrigger implements INodeType { // Some fields contain lower level fields of which we are only interested of the values const subvalueKeys = ['label', 'labels']; - if (simplifyAnswers === true) { + if (simplifyAnswers) { // Convert the answers to simple key -> value pairs const definition = (bodyData.form_response as IDataObject).definition as ITypeformDefinition; @@ -268,7 +268,7 @@ export class TypeformTrigger implements INodeType { convertedAnswers[defintitionsById[answer.field.id]] = value; } - if (onlyAnswers === true) { + if (onlyAnswers) { // Only the answers should be returned so do it directly return { workflowData: [this.helpers.returnJsonArray([convertedAnswers])], @@ -280,7 +280,7 @@ export class TypeformTrigger implements INodeType { } } - if (onlyAnswers === true) { + if (onlyAnswers) { // Return only the answer return { workflowData: [this.helpers.returnJsonArray([answers as unknown as IDataObject])], diff --git a/packages/nodes-base/nodes/UProc/ToolDescription.ts b/packages/nodes-base/nodes/UProc/ToolDescription.ts index a1d78bf1c0..9e5ed7eb23 100644 --- a/packages/nodes-base/nodes/UProc/ToolDescription.ts +++ b/packages/nodes-base/nodes/UProc/ToolDescription.ts @@ -60,7 +60,7 @@ let parameters = []; //all tools for (const tool of (tools as IDataObject).processors as IDataObject[]) { //all parameters in tool - for (const param of (tool as IDataObject).p as IDataObject[]) { + for (const param of tool.p as IDataObject[]) { const displayName = param.n as string; const capitalizedDisplayName = capitalize(displayName.replace(/_/g, ' ')); const description = `The "${capitalizedDisplayName}" value to use as a parameter for this Operation`; diff --git a/packages/nodes-base/nodes/UProc/UProc.node.ts b/packages/nodes-base/nodes/UProc/UProc.node.ts index e05744fa34..80a006751c 100644 --- a/packages/nodes-base/nodes/UProc/UProc.node.ts +++ b/packages/nodes-base/nodes/UProc/UProc.node.ts @@ -88,10 +88,7 @@ export class UProc implements INodeType { const fields = toolParameters .filter((field) => { return ( - field && - field.displayOptions && - field.displayOptions.show && - field.displayOptions.show.group && + field?.displayOptions?.show?.group && field.displayOptions.show.tool && field.displayOptions.show.group.indexOf(group) !== -1 && field.displayOptions.show.tool.indexOf(tool) !== -1 @@ -111,17 +108,17 @@ export class UProc implements INodeType { }; fields.forEach((field) => { - if (field && field.length) { + if (field?.length) { const data = this.getNodeParameter(field, i) as string; body.params[field] = data + ''; } }); - if (dataWebhook && dataWebhook.length) { + if (dataWebhook?.length) { body.callback = {}; } - if (dataWebhook && dataWebhook.length) { + if (dataWebhook?.length) { body.callback.data = dataWebhook; } diff --git a/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts b/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts index f0b7a4ecfd..d0eea6a8d7 100644 --- a/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts +++ b/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts @@ -209,7 +209,7 @@ export class UptimeRobot implements INodeType { if (operation === 'update') { body = { id: this.getNodeParameter('id', i) as string, - ...(this.getNodeParameter('updateFields', i) as IDataObject), + ...this.getNodeParameter('updateFields', i), }; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/editMonitor', body); @@ -253,7 +253,7 @@ export class UptimeRobot implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); body = { - ...(this.getNodeParameter('filters', i) as IDataObject), + ...this.getNodeParameter('filters', i), }; if (!returnAll) { @@ -271,7 +271,7 @@ export class UptimeRobot implements INodeType { if (operation === 'update') { body = { id: this.getNodeParameter('id', i) as string, - ...(this.getNodeParameter('updateFields', i) as IDataObject), + ...this.getNodeParameter('updateFields', i), }; responseData = await uptimeRobotApiRequest.call( @@ -301,10 +301,10 @@ export class UptimeRobot implements INodeType { }; if (type === 3) { - body['value'] = this.getNodeParameter('weekDay', i) as number; + body.value = this.getNodeParameter('weekDay', i) as number; } if (type === 4) { - body['value'] = this.getNodeParameter('monthDay', i) as number; + body.value = this.getNodeParameter('monthDay', i) as number; } responseData = await uptimeRobotApiRequest.call(this, 'POST', '/newMWindow', body); @@ -330,7 +330,7 @@ export class UptimeRobot implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); body = { - ...(this.getNodeParameter('filters', i) as IDataObject), + ...this.getNodeParameter('filters', i), }; if (!returnAll) { @@ -344,7 +344,7 @@ export class UptimeRobot implements INodeType { body = { id: this.getNodeParameter('id', i) as string, duration: this.getNodeParameter('duration', i) as string, - ...(this.getNodeParameter('updateFields', i) as IDataObject), + ...this.getNodeParameter('updateFields', i), }; if (body.type === 1 && body.start_time) { @@ -354,11 +354,11 @@ export class UptimeRobot implements INodeType { } if (body.type === 3) { - body['value'] = body.weekDay; + body.value = body.weekDay; delete body.weekDay; } if (body.type === 4) { - body['value'] = body.monthDay; + body.value = body.monthDay; delete body.monthDay; } responseData = await uptimeRobotApiRequest.call(this, 'POST', '/editMWindow', body); @@ -370,7 +370,7 @@ export class UptimeRobot implements INodeType { body = { friendly_name: this.getNodeParameter('friendlyName', i) as string, monitors: this.getNodeParameter('monitors', i) as string, - ...(this.getNodeParameter('additionalFields', i) as IDataObject), + ...this.getNodeParameter('additionalFields', i), }; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/newPSP', body); @@ -394,7 +394,7 @@ export class UptimeRobot implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); body = { - ...(this.getNodeParameter('filters', i) as IDataObject), + ...this.getNodeParameter('filters', i), }; if (!returnAll) { @@ -407,7 +407,7 @@ export class UptimeRobot implements INodeType { if (operation === 'update') { body = { id: this.getNodeParameter('id', i) as string, - ...(this.getNodeParameter('updateFields', i) as IDataObject), + ...this.getNodeParameter('updateFields', i), }; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/editPSP', body); responseData = responseData.psp; diff --git a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts index 4398559f51..252c65486c 100644 --- a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts @@ -40,7 +40,7 @@ export async function handleListing( qs.size = 100; - const returnAll = this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll = this.getNodeParameter('returnAll', 0, false); const limit = this.getNodeParameter('limit', 0, 0); do { diff --git a/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts b/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts index 0078ac8bd8..fbc6e18439 100644 --- a/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts @@ -47,7 +47,7 @@ export async function venafiApiRequest( options, ); } catch (error) { - if (error.response && error.response.body && error.response.body.error) { + if (error.response?.body?.error) { let errors = error.response.body.error.errors; errors = errors.map((e: IDataObject) => e.message); @@ -74,7 +74,7 @@ export async function venafiApiRequestAllItems( responseData = await venafiApiRequest.call(this, method, endpoint, body, query); endpoint = get(responseData, '_links[0].Next'); returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData._links && responseData._links[0].Next); + } while (responseData._links?.[0].Next); return returnData; } diff --git a/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts b/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts index 539d83ff1f..2861d7e8a2 100644 --- a/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts @@ -40,8 +40,8 @@ export async function venafiApiRequest( if (operation === 'download') { // We need content-type for keystore if (!resource.endsWith('keystore')) { - delete options!.headers!['Accept']; - delete options!.headers!['content-type']; + delete options.headers!.Accept; + delete options.headers!['content-type']; } } @@ -49,11 +49,7 @@ export async function venafiApiRequest( if (Object.keys(body).length === 0) { delete options.body; } - return await this.helpers.requestWithAuthentication.call( - this, - 'venafiTlsProtectCloudApi', - options, - ); + return this.helpers.requestWithAuthentication.call(this, 'venafiTlsProtectCloudApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } @@ -76,7 +72,7 @@ export async function venafiApiRequestAllItems( responseData = await venafiApiRequest.call(this, method, endpoint, body, query); endpoint = get(responseData, '_links[0].Next'); returnData.push.apply(returnData, responseData[propertyName]); - } while (responseData._links && responseData._links[0].Next); + } while (responseData._links?.[0].Next); return returnData; } @@ -112,7 +108,7 @@ export async function encryptPassphrase( let encryptedKeyPass = ''; let encryptedKeyStorePass = ''; - const promise = () => { + const promise = async () => { return new Promise((resolve, reject) => { nacl_factory.instantiate((nacl: any) => { try { @@ -134,5 +130,5 @@ export async function encryptPassphrase( }); }); }; - return await promise(); + return promise(); } diff --git a/packages/nodes-base/nodes/Venafi/ProtectCloud/VenafiTlsProtectCloud.node.ts b/packages/nodes-base/nodes/Venafi/ProtectCloud/VenafiTlsProtectCloud.node.ts index 1cc9398f4d..546c116dd0 100644 --- a/packages/nodes-base/nodes/Venafi/ProtectCloud/VenafiTlsProtectCloud.node.ts +++ b/packages/nodes-base/nodes/Venafi/ProtectCloud/VenafiTlsProtectCloud.node.ts @@ -170,9 +170,9 @@ export class VenafiTlsProtectCloud implements INodeType { const subjectAltNamesByType: ISubjectAltNamesByType = {}; body.isVaaSGenerated = true; - body.applicationServerTypeId = applicationServerTypeId as string; + body.applicationServerTypeId = applicationServerTypeId; - csrAttributes.commonName = commonName as string; + csrAttributes.commonName = commonName; // Csr Generation if (additionalFields.organization) { diff --git a/packages/nodes-base/nodes/Vero/Vero.node.ts b/packages/nodes-base/nodes/Vero/Vero.node.ts index e11b01c9a6..6707fe0ec6 100644 --- a/packages/nodes-base/nodes/Vero/Vero.node.ts +++ b/packages/nodes-base/nodes/Vero/Vero.node.ts @@ -86,9 +86,10 @@ export class Vero implements INodeType { ).dataAttributesValues as IDataObject[]; if (dataAttributesValues) { const dataAttributes = {}; - for (let i = 0; i < dataAttributesValues.length; i++) { + for (let index = 0; index < dataAttributesValues.length; index++) { // @ts-ignore - dataAttributes[dataAttributesValues[i].key] = dataAttributesValues[i].value; + dataAttributes[dataAttributesValues[index].key] = + dataAttributesValues[index].value; // @ts-ignore body.data = dataAttributes; } @@ -144,7 +145,7 @@ export class Vero implements INodeType { //https://developers.getvero.com/?bash#tags-remove if (operation === 'addTags' || operation === 'removeTags') { const id = this.getNodeParameter('id', i) as string; - const tags = (this.getNodeParameter('tags', i) as string).split(',') as string[]; + const tags = (this.getNodeParameter('tags', i) as string).split(','); const body = { id, }; @@ -182,9 +183,10 @@ export class Vero implements INodeType { ).dataAttributesValues as IDataObject[]; if (dataAttributesValues) { const dataAttributes = {}; - for (let i = 0; i < dataAttributesValues.length; i++) { + for (let index = 0; index < dataAttributesValues.length; index++) { // @ts-ignore - dataAttributes[dataAttributesValues[i].key] = dataAttributesValues[i].value; + dataAttributes[dataAttributesValues[index].key] = + dataAttributesValues[index].value; // @ts-ignore body.data = JSON.stringify(dataAttributes); } @@ -194,9 +196,10 @@ export class Vero implements INodeType { ).extraAttributesValues as IDataObject[]; if (extraAttributesValues) { const extraAttributes = {}; - for (let i = 0; i < extraAttributesValues.length; i++) { + for (let index = 0; index < extraAttributesValues.length; index++) { // @ts-ignore - extraAttributes[extraAttributesValues[i].key] = extraAttributesValues[i].value; + extraAttributes[extraAttributesValues[index].key] = + extraAttributesValues[index].value; // @ts-ignore body.extras = JSON.stringify(extraAttributes); } diff --git a/packages/nodes-base/nodes/Wait/Wait.node.ts b/packages/nodes-base/nodes/Wait/Wait.node.ts index bbf38a910e..b164ff9b0e 100644 --- a/packages/nodes-base/nodes/Wait/Wait.node.ts +++ b/packages/nodes-base/nodes/Wait/Wait.node.ts @@ -642,8 +642,8 @@ export class Wait implements INodeType { } if ( - basicAuthData.name !== httpBasicAuth!.user || - basicAuthData.pass !== httpBasicAuth!.password + basicAuthData.name !== httpBasicAuth.user || + basicAuthData.pass !== httpBasicAuth.password ) { // Provided authentication data is wrong return authorizationError(resp, realm, 403); @@ -707,7 +707,7 @@ export class Wait implements INodeType { if (binaryPropertyName.endsWith('[]')) { binaryPropertyName = binaryPropertyName.slice(0, -2); } - if (multiFile === true) { + if (multiFile) { binaryPropertyName += fileCount++; } if (options.binaryPropertyName) { diff --git a/packages/nodes-base/nodes/Webflow/Webflow.node.ts b/packages/nodes-base/nodes/Webflow/Webflow.node.ts index 7f90433eac..3cc7e22d8a 100644 --- a/packages/nodes-base/nodes/Webflow/Webflow.node.ts +++ b/packages/nodes-base/nodes/Webflow/Webflow.node.ts @@ -219,7 +219,7 @@ export class Webflow implements INodeType { const collectionId = this.getNodeParameter('collectionId', i) as string; const qs: IDataObject = {}; - if (returnAll === true) { + if (returnAll) { responseData = await webflowApiRequestAllItems.call( this, 'GET', diff --git a/packages/nodes-base/nodes/Webhook/Webhook.node.ts b/packages/nodes-base/nodes/Webhook/Webhook.node.ts index 27e64c1ac1..2e9d4d2134 100644 --- a/packages/nodes-base/nodes/Webhook/Webhook.node.ts +++ b/packages/nodes-base/nodes/Webhook/Webhook.node.ts @@ -455,8 +455,8 @@ export class Webhook implements INodeType { } if ( - basicAuthData.name !== httpBasicAuth!.user || - basicAuthData.pass !== httpBasicAuth!.password + basicAuthData.name !== httpBasicAuth.user || + basicAuthData.pass !== httpBasicAuth.password ) { // Provided authentication data is wrong return authorizationError(resp, realm, 403); @@ -519,7 +519,7 @@ export class Webhook implements INodeType { if (binaryPropertyName.endsWith('[]')) { binaryPropertyName = binaryPropertyName.slice(0, -2); } - if (multiFile === true) { + if (multiFile) { binaryPropertyName += fileCount++; } if (options.binaryPropertyName) { diff --git a/packages/nodes-base/nodes/WhatsApp/MessageFunctions.ts b/packages/nodes-base/nodes/WhatsApp/MessageFunctions.ts index bbf0972fd1..98508b8772 100644 --- a/packages/nodes-base/nodes/WhatsApp/MessageFunctions.ts +++ b/packages/nodes-base/nodes/WhatsApp/MessageFunctions.ts @@ -39,7 +39,7 @@ export async function addTemplateComponents( if (!requestOptions.body) { requestOptions.body = {}; } - set(requestOptions.body as {}, 'template.components', components); + set(requestOptions.body as IDataObject, 'template.components', components); return requestOptions; } @@ -100,9 +100,13 @@ export async function mediaUploadFromItem( if (!requestOptions.body) { requestOptions.body = {}; } - set(requestOptions.body as {}, `${operation}.id`, result.id); + set(requestOptions.body as IDataObject, `${operation}.id`, result.id); if (operation === 'document') { - set(requestOptions.body as {}, `${operation}.filename`, mediaFileName || binaryFileName); + set( + requestOptions.body as IDataObject, + `${operation}.filename`, + mediaFileName || binaryFileName, + ); } return requestOptions; @@ -117,8 +121,8 @@ export async function templateInfo( if (!requestOptions.body) { requestOptions.body = {}; } - set(requestOptions.body as {}, 'template.name', name); - set(requestOptions.body as {}, 'template.language.code', language); + set(requestOptions.body as IDataObject, 'template.name', name); + set(requestOptions.body as IDataObject, 'template.language.code', language); return requestOptions; } @@ -187,7 +191,7 @@ export async function componentsRequest( requestOptions.body = {}; } - set(requestOptions.body as {}, 'template.components', componentsRet); + set(requestOptions.body as IDataObject, 'template.components', componentsRet); return requestOptions; } @@ -203,7 +207,7 @@ export async function cleanPhoneNumber( requestOptions.body = {}; } - set(requestOptions.body as {}, 'to', phoneNumber); + set(requestOptions.body as IDataObject, 'to', phoneNumber); return requestOptions; } diff --git a/packages/nodes-base/nodes/Wise/GenericFunctions.ts b/packages/nodes-base/nodes/Wise/GenericFunctions.ts index 6aeb215d78..be10658cd4 100644 --- a/packages/nodes-base/nodes/Wise/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wise/GenericFunctions.ts @@ -63,7 +63,7 @@ export async function wiseApiRequest( let response; try { - response = await this.helpers.httpRequest!(options); + response = await this.helpers.httpRequest(options); } catch (error) { delete error.config; throw new NodeApiError(this.getNode(), error); @@ -102,7 +102,7 @@ export async function wiseApiRequest( } // Retry the request with signed token try { - response = await this.helpers.httpRequest!(options); + response = await this.helpers.httpRequest(options); return response.body; } catch (error) { throw new NodeApiError(this.getNode(), { diff --git a/packages/nodes-base/nodes/Wise/Wise.node.ts b/packages/nodes-base/nodes/Wise/Wise.node.ts index d4b52dc913..46705feb7a 100644 --- a/packages/nodes-base/nodes/Wise/Wise.node.ts +++ b/packages/nodes-base/nodes/Wise/Wise.node.ts @@ -449,11 +449,15 @@ export class Wise implements INodeType { const { environment } = await this.getCredentials('wiseApi'); if (environment === 'test') { - for (const endpoint of ['processing', 'funds_converted', 'outgoing_payment_sent']) { + for (const testEndpoint of [ + 'processing', + 'funds_converted', + 'outgoing_payment_sent', + ]) { await wiseApiRequest.call( this, 'GET', - `v1/simulation/transfers/${transferId}/${endpoint}`, + `v1/simulation/transfers/${transferId}/${testEndpoint}`, ); } } diff --git a/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts b/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts index 24bf362732..0c643f64f4 100644 --- a/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts +++ b/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts @@ -97,6 +97,7 @@ export class WiseTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { @@ -185,7 +186,7 @@ export class WiseTrigger implements INodeType { const sig = createVerify('RSA-SHA1').update(req.rawBody); const verified = sig.verify(publicKey, signature, 'base64'); - if (verified === false) { + if (!verified) { return {}; } diff --git a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts index 49139a89dc..fa4b499bde 100644 --- a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts @@ -73,10 +73,7 @@ export async function woocommerceApiRequestAllItems( uri = nextLink.split(';')[0].replace(/<(.*)>/, '$1'); } returnData.push.apply(returnData, responseData.body); - } while ( - responseData.headers['link'] !== undefined && - responseData.headers['link'].includes('rel="next"') - ); + } while (responseData.headers.link?.includes('rel="next"')); return returnData; } @@ -95,7 +92,7 @@ export function setMetadata( ) { for (let i = 0; i < data.length; i++) { //@ts-ignore\ - if (data[i].metadataUi && data[i].metadataUi.metadataValues) { + if (data[i].metadataUi?.metadataValues) { //@ts-ignore data[i].meta_data = data[i].metadataUi.metadataValues; //@ts-ignore @@ -134,7 +131,7 @@ export function toSnakeCase( export function setFields(fieldsToSet: IDataObject, body: IDataObject) { for (const fields in fieldsToSet) { if (fields === 'tags') { - body['tags'] = (fieldsToSet[fields] as string[]).map((tag) => ({ id: parseInt(tag, 10) })); + body.tags = (fieldsToSet[fields] as string[]).map((tag) => ({ id: parseInt(tag, 10) })); } else { body[snakeCase(fields.toString())] = fieldsToSet[fields]; } diff --git a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts index f9cb92043e..484dd7ec7b 100644 --- a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts +++ b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts @@ -164,9 +164,7 @@ export class WooCommerce implements INodeType { const customerId = this.getNodeParameter('customerId', i); - const qs: IDataObject = { - force: true, // required, customers do not support trashing - }; + qs.force = true; // required, customers do not support trashing const endpoint = `/customers/${customerId}`; responseData = await woocommerceApiRequest.call(this, 'DELETE', endpoint, {}, qs); @@ -188,7 +186,6 @@ export class WooCommerce implements INodeType { // https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#list-all-customers - const qs = {} as IDataObject; const filters = this.getNodeParameter('filters', i); const returnAll = this.getNodeParameter('returnAll', i); @@ -202,7 +199,7 @@ export class WooCommerce implements INodeType { 'GET', '/customers', {}, - qs, + {}, ); } else { qs.per_page = this.getNodeParameter('limit', i); @@ -357,7 +354,7 @@ export class WooCommerce implements INodeType { if (options.type) { qs.type = options.type as string; } - if (returnAll === true) { + if (returnAll) { responseData = await woocommerceApiRequestAllItems.call( this, 'GET', @@ -562,7 +559,7 @@ export class WooCommerce implements INodeType { if (options.status) { qs.status = options.status as string; } - if (returnAll === true) { + if (returnAll) { responseData = await woocommerceApiRequestAllItems.call(this, 'GET', '/orders', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', i); diff --git a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts index 26a8ee9ddf..bfcf68b0da 100644 --- a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function wordpressApiRequest( method, qs, body, - uri: uri || `${credentials!.url}/wp-json/wp/v2${resource}`, + uri: uri || `${credentials.url}/wp-json/wp/v2${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -34,7 +34,7 @@ export async function wordpressApiRequest( } try { const credentialType = 'wordpressApi'; - return this.helpers.requestWithAuthentication.call(this, credentialType, options); + return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts b/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts index 75e8c520bb..ed48f55e60 100644 --- a/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts +++ b/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts @@ -282,7 +282,7 @@ export class Wordpress implements INodeType { if (options.status) { qs.status = options.status as string; } - if (returnAll === true) { + if (returnAll) { responseData = await wordpressApiRequestAllItems.call(this, 'GET', '/posts', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', i); @@ -404,7 +404,7 @@ export class Wordpress implements INodeType { if (options.who) { qs.who = options.who as string; } - if (returnAll === true) { + if (returnAll) { responseData = await wordpressApiRequestAllItems.call(this, 'GET', '/users', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', i); diff --git a/packages/nodes-base/nodes/WriteBinaryFile/WriteBinaryFile.node.ts b/packages/nodes-base/nodes/WriteBinaryFile/WriteBinaryFile.node.ts index 6d3d4ba3c2..c630081092 100644 --- a/packages/nodes-base/nodes/WriteBinaryFile/WriteBinaryFile.node.ts +++ b/packages/nodes-base/nodes/WriteBinaryFile/WriteBinaryFile.node.ts @@ -1,6 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; import { - IDataObject, INodeExecutionData, INodeType, INodeTypeDescription, @@ -73,7 +72,7 @@ export class WriteBinaryFile implements INodeType { const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; const fileName = this.getNodeParameter('fileName', itemIndex) as string; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); const flag = options.append ? 'a' : 'w'; @@ -121,7 +120,7 @@ export class WriteBinaryFile implements INodeType { // Add the file name to data - (newItem.json as IDataObject).fileName = fileName; + newItem.json.fileName = fileName; returnData.push(newItem); } catch (error) { diff --git a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts index ccb2a76a27..456266b4c6 100644 --- a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function wufooApiRequest( form: body, body, qs, - uri: `https://${credentials!.subdomain}.wufoo.com/api/v3/${resource}`, + uri: `https://${credentials.subdomain}.wufoo.com/api/v3/${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts b/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts index 409d16f1ed..63f02a72bb 100644 --- a/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts +++ b/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts @@ -114,10 +114,10 @@ export class WufooTrigger implements INodeType { const endpoint = `forms/${formHash}/webhooks.json`; // Handshake key for webhook endpoint protection - webhookData.handshakeKey = randomBytes(20).toString('hex') as string; + webhookData.handshakeKey = randomBytes(20).toString('hex'); const body: IWebhook = { url: webhookUrl as string, - handshakeKey: webhookData.handshakeKey as string, + handshakeKey: webhookData.handshakeKey, metadata: true, }; @@ -203,7 +203,7 @@ export class WufooTrigger implements INodeType { } }); - if (onlyAnswers === false) { + if (!onlyAnswers) { returnObject = { createdBy: req.body.CreatedBy as string, entryId: req.body.EntryId as number, diff --git a/packages/nodes-base/nodes/Xml/Xml.node.ts b/packages/nodes-base/nodes/Xml/Xml.node.ts index 1453126659..1a82957386 100644 --- a/packages/nodes-base/nodes/Xml/Xml.node.ts +++ b/packages/nodes-base/nodes/Xml/Xml.node.ts @@ -1,7 +1,6 @@ import { Builder, Parser } from 'xml2js'; import { IExecuteFunctions } from 'n8n-core'; import { - IDataObject, INodeExecutionData, INodeType, INodeTypeDescription, @@ -222,7 +221,7 @@ export class Xml implements INodeType { const mode = this.getNodeParameter('mode', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; - const options = this.getNodeParameter('options', 0, {}) as IDataObject; + const options = this.getNodeParameter('options', 0, {}); let item: INodeExecutionData; const returnData: INodeExecutionData[] = []; diff --git a/packages/nodes-base/nodes/Zammad/GenericFunctions.ts b/packages/nodes-base/nodes/Zammad/GenericFunctions.ts index 50fef6e6fc..9ec38bd715 100644 --- a/packages/nodes-base/nodes/Zammad/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zammad/GenericFunctions.ts @@ -65,7 +65,7 @@ export async function zammadApiRequest( } try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { if (error.error.error === 'Object already exists!') { error.error.error = 'An entity with this name already exists.'; diff --git a/packages/nodes-base/nodes/Zammad/Zammad.node.ts b/packages/nodes-base/nodes/Zammad/Zammad.node.ts index 959fe3ee14..61fda8bd1f 100644 --- a/packages/nodes-base/nodes/Zammad/Zammad.node.ts +++ b/packages/nodes-base/nodes/Zammad/Zammad.node.ts @@ -352,7 +352,7 @@ export class Zammad implements INodeType { Object.assign(body, addressUi?.addressDetails); customFieldsUi?.customFieldPairs.forEach((pair) => { - body[pair['name']] = pair['value']; + body[pair.name] = pair.value; }); Object.assign(body, rest); @@ -383,7 +383,7 @@ export class Zammad implements INodeType { Object.assign(body, addressUi?.addressDetails); customFieldsUi?.customFieldPairs.forEach((pair) => { - body[pair['name']] = pair['value']; + body[pair.name] = pair.value; }); Object.assign(body, rest); @@ -438,10 +438,10 @@ export class Zammad implements INodeType { responseData = await zammadApiRequestAllItems .call(this, 'GET', '/users/search', {}, qs, limit) - .then((responseData) => { - return responseData.map((user) => { - const { _preferences, ...rest } = user; - return rest; + .then((response) => { + return response.map((user) => { + const { _preferences, ...data } = user; + return data; }); }); } else if (operation === 'getSelf') { @@ -475,7 +475,7 @@ export class Zammad implements INodeType { ) as ZammadTypes.UserAdditionalFields; customFieldsUi?.customFieldPairs.forEach((pair) => { - body[pair['name']] = pair['value']; + body[pair.name] = pair.value; }); Object.assign(body, rest); @@ -504,7 +504,7 @@ export class Zammad implements INodeType { const { customFieldsUi, ...rest } = updateFields; customFieldsUi?.customFieldPairs.forEach((pair) => { - body[pair['name']] = pair['value']; + body[pair.name] = pair.value; }); Object.assign(body, rest); @@ -575,7 +575,7 @@ export class Zammad implements INodeType { ) as ZammadTypes.UserAdditionalFields; customFieldsUi?.customFieldPairs.forEach((pair) => { - body[pair['name']] = pair['value']; + body[pair.name] = pair.value; }); Object.assign(body, rest); @@ -604,7 +604,7 @@ export class Zammad implements INodeType { const { customFieldsUi, ...rest } = updateFields; customFieldsUi?.customFieldPairs.forEach((pair) => { - body[pair['name']] = pair['value']; + body[pair.name] = pair.value; }); Object.assign(body, rest); diff --git a/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts b/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts index 3ae8ddcdd4..878b2c01ab 100644 --- a/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts +++ b/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts @@ -536,11 +536,11 @@ export class Zendesk implements INodeType { Object.assign(body, additionalFields); if (body.userFieldsUi) { - const userFields = (body.userFieldsUi as IDataObject) + const userFieldsUI = (body.userFieldsUi as IDataObject) .userFieldValues as IDataObject[]; - if (userFields) { + if (userFieldsUI) { body.user_fields = {}; - for (const userField of userFields) { + for (const userField of userFieldsUI) { //@ts-ignore body.user_fields[userField.field] = userField.value; } @@ -560,11 +560,11 @@ export class Zendesk implements INodeType { Object.assign(body, updateFields); if (body.userFieldsUi) { - const userFields = (body.userFieldsUi as IDataObject) + const userFieldsUI = (body.userFieldsUi as IDataObject) .userFieldValues as IDataObject[]; - if (userFields) { + if (userFieldsUI) { body.user_fields = {}; - for (const userField of userFields) { + for (const userField of userFieldsUI) { //@ts-ignore body.user_fields[userField.field] = userField.value; } @@ -683,10 +683,10 @@ export class Zendesk implements INodeType { Object.assign(body, rest); if (organizationFieldsUi?.organizationFieldValues.length) { - const organizationFields = organizationFieldsUi.organizationFieldValues; - if (organizationFields.length) { + const organizationFieldsUI = organizationFieldsUi.organizationFieldValues; + if (organizationFieldsUI.length) { body.organization_fields = {}; - for (const organizationField of organizationFields) { + for (const organizationField of organizationFieldsUI) { body.organization_fields[organizationField.field] = organizationField.value; } } @@ -769,10 +769,10 @@ export class Zendesk implements INodeType { Object.assign(body, rest); if (organizationFieldsUi?.organizationFieldValues.length) { - const organizationFields = organizationFieldsUi.organizationFieldValues; - if (organizationFields.length) { + const organizationFieldsUI = organizationFieldsUi.organizationFieldValues; + if (organizationFieldsUI.length) { body.organization_fields = {}; - for (const organizationField of organizationFields) { + for (const organizationField of organizationFieldsUI) { body.organization_fields[organizationField.field] = organizationField.value; } } diff --git a/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts b/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts index 5c772ea930..21afe1de6d 100644 --- a/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts +++ b/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts @@ -141,6 +141,7 @@ export class ZendeskTrigger implements INodeType { }, ], }; + methods = { loadOptions: { // Get all the fields to display them to user so that he can @@ -216,6 +217,7 @@ export class ZendeskTrigger implements INodeType { }, }, }; + // @ts-ignore webhookMethods = { default: { diff --git a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts index 8f98bdf09e..4ee047d6c7 100644 --- a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts @@ -104,7 +104,7 @@ export async function handleListing( const returnAll = this.getNodeParameter('returnAll', 0); if (returnAll) { - return await zohoApiRequestAllItems.call(this, method, endpoint, body, qs); + return zohoApiRequestAllItems.call(this, method, endpoint, body, qs); } const responseData = await zohoApiRequestAllItems.call(this, method, endpoint, body, qs); diff --git a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts index 903bae2819..ffb075b22b 100644 --- a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts @@ -10,9 +10,9 @@ export async function zoomApiRequest( resource: string, body: object = {}, query: object = {}, - headers: {} | undefined = undefined, - option: {} = {}, -): Promise { + headers: IDataObject | undefined = undefined, + option: IDataObject = {}, +) { const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; let options: OptionsWithUri = { @@ -52,7 +52,7 @@ export async function zoomApiRequestAllItems( endpoint: string, body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; let responseData; query.page_number = 0; @@ -67,7 +67,7 @@ export async function zoomApiRequestAllItems( return returnData; } -function wait() { +async function wait() { return new Promise((resolve, _reject) => { setTimeout(() => { resolve(true); diff --git a/packages/nodes-base/nodes/Zoom/Zoom.node.ts b/packages/nodes-base/nodes/Zoom/Zoom.node.ts index 23710f2859..37be69327a 100644 --- a/packages/nodes-base/nodes/Zoom/Zoom.node.ts +++ b/packages/nodes-base/nodes/Zoom/Zoom.node.ts @@ -133,6 +133,7 @@ export class Zoom implements INodeType { // ...webinarFields, ], }; + methods = { loadOptions: { // Get all the timezones to display them to user so that he can select them easily diff --git a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts index c1faa37a54..6fca05bd62 100644 --- a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts @@ -40,7 +40,7 @@ export async function zulipApiRequest( } options = Object.assign({}, options, option); try { - return await this.helpers.request!(options); + return this.helpers.request!(options); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Zulip/UserInterface.ts b/packages/nodes-base/nodes/Zulip/UserInterface.ts index 12ff6d63b5..e79acff785 100644 --- a/packages/nodes-base/nodes/Zulip/UserInterface.ts +++ b/packages/nodes-base/nodes/Zulip/UserInterface.ts @@ -1,10 +1,12 @@ +import { IDataObject } from 'n8n-workflow'; + export interface IUser { client_gravatar?: boolean; include_custom_profile_fields?: boolean; full_name?: string; is_admin?: boolean; is_guest?: boolean; - profile_data?: [{}]; + profile_data?: [IDataObject]; email?: string; password?: string; short_name?: string; diff --git a/packages/nodes-base/nodes/Zulip/Zulip.node.ts b/packages/nodes-base/nodes/Zulip/Zulip.node.ts index 2134b0e49d..00e6fd97c2 100644 --- a/packages/nodes-base/nodes/Zulip/Zulip.node.ts +++ b/packages/nodes-base/nodes/Zulip/Zulip.node.ts @@ -8,14 +8,13 @@ import { INodeTypeDescription, NodeOperationError, } from 'n8n-workflow'; -import { zulipApiRequest } from './GenericFunctions'; +import { validateJSON, zulipApiRequest } from './GenericFunctions'; import { messageFields, messageOperations } from './MessageDescription'; import { IMessage } from './MessageInterface'; import { snakeCase } from 'change-case'; import { streamFields, streamOperations } from './StreamDescription'; import { userFields, userOperations } from './UserDescription'; import { IPrincipal, IStream } from './StreamInterface'; -import { validateJSON } from './GenericFunctions'; import { IUser } from './UserInterface'; export class Zulip implements INodeType { @@ -295,7 +294,6 @@ export class Zulip implements INodeType { } else { const additionalFields = this.getNodeParameter('additionalFields', i); - const subscriptions = this.getNodeParameter('subscriptions', i) as IDataObject; body.subscriptions = JSON.stringify(subscriptions.properties); if (additionalFields.inviteOnly) { @@ -454,7 +452,7 @@ export class Zulip implements INodeType { } if (additionalFields.profileData) { //@ts-ignore - body.profile_data = additionalFields.profileData.properties as [{}]; + body.profile_data = additionalFields.profileData.properties as [IDataObject]; } responseData = await zulipApiRequest.call(this, 'PATCH', `/users/${userId}`, body);