From 100d9bc0879511eb72b1485b676483c4fc3cf13f Mon Sep 17 00:00:00 2001 From: Elias Meire Date: Wed, 14 Feb 2024 16:29:09 +0100 Subject: [PATCH] refactor: Add IRequestOptions type to helpers.request for more type safety (no-changelog) (#8563) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ --- packages/@n8n/nodes-langchain/package.json | 1 - packages/core/package.json | 1 - packages/core/src/NodeExecuteFunctions.ts | 103 ++++++++---------- .../nodes-base/credentials/Aws.credentials.ts | 10 +- .../nodes/ActionNetwork/GenericFunctions.ts | 24 ++-- .../ActiveCampaign/ActiveCampaign.node.ts | 3 +- .../nodes/ActiveCampaign/GenericFunctions.ts | 10 +- .../AcuityScheduling/GenericFunctions.ts | 7 +- .../nodes/Affinity/GenericFunctions.ts | 10 +- .../nodes/AgileCrm/GenericFunctions.ts | 14 +-- .../nodes/Airtable/v1/AirtableV1.node.ts | 3 +- .../nodes/Airtable/v1/GenericFunctions.ts | 10 +- .../nodes/Airtable/v2/transport/index.ts | 10 +- .../nodes/ApiTemplateIo/GenericFunctions.ts | 14 ++- .../nodes/Automizy/GenericFunctions.ts | 10 +- .../nodes/Autopilot/Autopilot.node.ts | 3 +- .../nodes/Autopilot/GenericFunctions.ts | 11 +- .../CertificateManager/GenericFunctions.ts | 7 +- .../nodes/Aws/Comprehend/GenericFunctions.ts | 7 +- .../nodes/Aws/DynamoDB/GenericFunctions.ts | 5 +- .../nodes/Aws/ELB/GenericFunctions.ts | 9 +- .../nodes-base/nodes/Aws/GenericFunctions.ts | 7 +- .../nodes/Aws/Rekognition/GenericFunctions.ts | 9 +- .../nodes/Aws/S3/V1/GenericFunctions.ts | 9 +- .../nodes/Aws/S3/V2/GenericFunctions.ts | 7 +- .../nodes/Aws/SES/GenericFunctions.ts | 9 +- .../nodes/Aws/Textract/GenericFunctions.ts | 12 +- .../nodes/Aws/Transcribe/GenericFunctions.ts | 12 +- .../nodes/BambooHr/v1/transport/index.ts | 5 +- .../nodes/Bannerbear/GenericFunctions.ts | 8 +- .../nodes/Baserow/GenericFunctions.ts | 12 +- .../nodes/Beeminder/GenericFunctions.ts | 10 +- .../nodes/Bitbucket/BitbucketTrigger.node.ts | 5 +- .../nodes/Bitbucket/GenericFunctions.ts | 9 +- .../nodes/Bitly/GenericFunctions.ts | 10 +- .../nodes/Bitwarden/GenericFunctions.ts | 12 +- .../nodes-base/nodes/Box/GenericFunctions.ts | 10 +- .../nodes/Brandfetch/GenericFunctions.ts | 8 +- .../nodes/Brevo/GenericFunctions.ts | 8 +- .../nodes/Bubble/GenericFunctions.ts | 10 +- .../nodes/Calendly/GenericFunctions.ts | 10 +- .../nodes/Chargebee/Chargebee.node.ts | 6 +- .../nodes/CircleCi/GenericFunctions.ts | 10 +- .../nodes/Cisco/Webex/GenericFunctions.ts | 9 +- .../nodes/Citrix/ADC/GenericFunctions.ts | 8 +- .../nodes/Clearbit/GenericFunctions.ts | 8 +- .../nodes/ClickUp/GenericFunctions.ts | 10 +- .../nodes/Clockify/GenericFunctions.ts | 10 +- .../nodes/Cloudflare/GenericFunctions.ts | 10 +- .../nodes/Cockpit/CollectionFunctions.ts | 4 +- .../nodes-base/nodes/Cockpit/FormFunctions.ts | 2 +- .../nodes/Cockpit/GenericFunctions.ts | 7 +- .../nodes/Cockpit/SingletonFunctions.ts | 2 +- .../nodes-base/nodes/Coda/GenericFunctions.ts | 9 +- .../nodes/CoinGecko/GenericFunctions.ts | 10 +- .../nodes/Contentful/GenericFunctions.ts | 10 +- .../nodes/ConvertKit/GenericFunctions.ts | 8 +- .../nodes/Copper/GenericFunctions.ts | 12 +- .../nodes/Cortex/GenericFunctions.ts | 8 +- .../nodes/CustomerIo/GenericFunctions.ts | 4 +- .../nodes/DeepL/GenericFunctions.ts | 8 +- .../nodes/Demio/GenericFunctions.ts | 8 +- .../nodes-base/nodes/Dhl/GenericFunctions.ts | 10 +- .../Discord/test/v2/node/channel/get.test.ts | 5 +- .../nodes/Discord/v1/DiscordV1.node.ts | 3 +- .../nodes/Discord/v2/transport/discord.api.ts | 12 +- .../nodes/Discord/v2/transport/helpers.ts | 5 +- .../nodes/Discourse/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Disqus/Disqus.node.ts | 3 +- .../nodes/Disqus/GenericFunctions.ts | 9 +- .../nodes/Drift/GenericFunctions.ts | 8 +- .../nodes-base/nodes/Dropbox/Dropbox.node.ts | 3 +- .../nodes/Dropbox/GenericFunctions.ts | 19 ++-- .../nodes/Dropcontact/GenericFunction.ts | 8 +- .../nodes/ERPNext/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Egoi/GenericFunctions.ts | 10 +- .../ElasticSecurity/ElasticSecurity.node.ts | 4 +- .../ElasticSecurity/GenericFunctions.ts | 12 +- .../Elastic/Elasticsearch/GenericFunctions.ts | 14 ++- .../nodes/Emelia/GenericFunctions.ts | 9 +- .../nodes/Eventbrite/GenericFunctions.ts | 10 +- .../nodes/ExecuteWorkflow/GenericFunctions.ts | 4 +- .../nodes/Facebook/FacebookGraphApi.node.ts | 24 ++-- .../nodes/Facebook/GenericFunctions.ts | 8 +- .../nodes/FacebookLeadAds/GenericFunctions.ts | 18 +-- .../nodes/Figma/GenericFunctions.ts | 8 +- .../nodes/FileMaker/FileMaker.node.ts | 4 +- .../nodes/FileMaker/GenericFunctions.ts | 15 ++- .../nodes-base/nodes/Flow/GenericFunctions.ts | 9 +- .../nodes/FormIo/GenericFunctions.ts | 6 +- .../nodes/Formstack/GenericFunctions.ts | 10 +- .../nodes/Freshdesk/GenericFunctions.ts | 10 +- .../nodes/Freshservice/GenericFunctions.ts | 12 +- .../nodes/FreshworksCrm/GenericFunctions.ts | 12 +- .../nodes/GetResponse/GenericFunctions.ts | 10 +- .../nodes/Ghost/GenericFunctions.ts | 10 +- .../nodes/Github/GenericFunctions.ts | 12 +- .../nodes-base/nodes/Github/Github.node.ts | 3 +- .../nodes/Gitlab/GenericFunctions.ts | 18 ++- .../nodes-base/nodes/Gitlab/Gitlab.node.ts | 3 +- .../nodes/GoToWebinar/GenericFunctions.ts | 10 +- .../Google/Analytics/v1/GenericFunctions.ts | 9 +- .../Analytics/v1/GoogleAnalyticsV1.node.ts | 3 +- .../Google/Analytics/v2/transport/index.ts | 9 +- .../test/v2/node/executeQuery.test.ts | 2 +- .../test/v2/node/insert.autoMapMode.test.ts | 2 +- .../test/v2/node/insert.manualMode.test.ts | 2 +- .../Google/BigQuery/v1/GenericFunctions.ts | 10 +- .../Google/BigQuery/v2/transport/index.ts | 10 +- .../nodes/Google/Books/GenericFunctions.ts | 10 +- .../nodes/Google/Calendar/GenericFunctions.ts | 10 +- .../nodes/Google/Chat/GenericFunctions.ts | 10 +- .../nodes/Google/Chat/GoogleChat.node.ts | 4 +- .../CloudNaturalLanguage/GenericFunctions.ts | 12 +- .../nodes/Google/Contacts/GenericFunctions.ts | 14 +-- .../nodes/Google/Docs/GenericFunctions.ts | 14 +-- .../Drive/test/v2/node/drive/list.test.ts | 4 +- .../Drive/test/v2/node/file/move.test.ts | 2 +- .../Drive/test/v2/node/file/upload.test.ts | 2 +- .../test/v2/node/fileFolder/search.test.ts | 4 +- .../nodes/Google/Drive/v1/GenericFunctions.ts | 10 +- .../CloudFirestore/GenericFunctions.ts | 10 +- .../RealtimeDatabase/GenericFunctions.ts | 14 +-- .../GoogleFirebaseRealtimeDatabase.node.ts | 3 +- .../Google/GSuiteAdmin/GenericFunctions.ts | 10 +- .../nodes/Google/GenericFunctions.ts | 4 +- .../nodes/Google/Gmail/GenericFunctions.ts | 10 +- .../nodes/Google/Gmail/v1/GmailV1.node.ts | 3 +- .../Google/Perspective/GenericFunctions.ts | 6 +- .../nodes/Google/Sheet/v1/GenericFunctions.ts | 10 +- .../nodes/Google/Sheet/v2/transport/index.ts | 9 +- .../nodes/Google/Slides/GenericFunctions.ts | 12 +- .../nodes/Google/Task/GenericFunctions.ts | 14 +-- .../Google/Translate/GenericFunctions.ts | 14 +-- .../nodes/Google/YouTube/GenericFunctions.ts | 10 +- .../nodes/Gotify/GenericFunctions.ts | 10 +- .../nodes/Grafana/GenericFunctions.ts | 8 +- .../nodes-base/nodes/GraphQL/GraphQL.node.ts | 28 ++--- .../nodes/Grist/GenericFunctions.ts | 8 +- packages/nodes-base/nodes/Grist/Grist.node.ts | 5 +- .../nodes/Gumroad/GenericFunctions.ts | 7 +- .../nodes/HackerNews/GenericFunctions.ts | 10 +- .../nodes/HaloPSA/GenericFunctions.ts | 16 +-- .../nodes/Harvest/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Harvest/Harvest.node.ts | 3 +- .../nodes/HelpScout/GenericFunctions.ts | 10 +- .../nodes/HighLevel/GenericFunctions.ts | 8 +- .../nodes/HomeAssistant/GenericFunctions.ts | 8 +- .../nodes/HttpRequest/GenericFunctions.ts | 14 ++- .../HttpRequest/V1/HttpRequestV1.node.ts | 20 ++-- .../HttpRequest/V2/HttpRequestV2.node.ts | 18 +-- .../HttpRequest/V3/HttpRequestV3.node.ts | 15 ++- .../nodes/Hubspot/V1/GenericFunctions.ts | 18 +-- .../nodes/Hubspot/V2/GenericFunctions.ts | 14 +-- .../nodes/HumanticAI/GenericFunctions.ts | 10 +- .../nodes/Hunter/GenericFunctions.ts | 9 +- .../nodes/Intercom/GenericFunctions.ts | 10 +- .../nodes/InvoiceNinja/GenericFunctions.ts | 10 +- .../nodes/Iterable/GenericFunctions.ts | 14 +-- .../nodes/Jenkins/GenericFunctions.ts | 8 +- .../nodes-base/nodes/Jira/GenericFunctions.ts | 10 +- .../nodes/JotForm/GenericFunctions.ts | 7 +- .../nodes-base/nodes/Keap/GenericFunctions.ts | 10 +- packages/nodes-base/nodes/Keap/Keap.node.ts | 4 +- .../nodes/Kitemaker/GenericFunctions.ts | 3 +- .../nodes/Lemlist/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Line/GenericFunctions.ts | 8 +- .../nodes/Linear/GenericFunctions.ts | 7 +- .../nodes/LingvaNex/GenericFunctions.ts | 8 +- .../nodes/LinkedIn/GenericFunctions.ts | 8 +- .../nodes/LoneScale/GenericFunctions.ts | 8 +- .../nodes/Magento/GenericFunctions.ts | 10 +- .../nodes/Mailcheck/GenericFunctions.ts | 8 +- .../nodes/Mailchimp/GenericFunctions.ts | 12 +- .../nodes/MailerLite/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Mailgun/Mailgun.node.ts | 3 +- .../nodes/Mailjet/GenericFunctions.ts | 10 +- .../nodes/Mandrill/GenericFunctions.ts | 11 +- .../nodes/Marketstack/GenericFunctions.ts | 16 ++- .../nodes/Matrix/GenericFunctions.ts | 10 +- .../nodes/Mautic/GenericFunctions.ts | 9 +- .../nodes/Medium/GenericFunctions.ts | 8 +- .../nodes/MessageBird/GenericFunctions.ts | 15 ++- .../nodes/MessageBird/MessageBird.node.ts | 3 +- .../Microsoft/Dynamics/GenericFunctions.ts | 10 +- .../Excel/test/v2/node/table/addTable.test.ts | 2 +- .../Excel/test/v2/node/table/append.test.ts | 2 +- .../test/v2/node/table/convertToRange.test.ts | 2 +- .../test/v2/node/table/deleteTable.test.ts | 2 +- .../Excel/test/v2/node/table/getRows.test.ts | 2 +- .../Excel/test/v2/node/table/lookup.test.ts | 2 +- .../v2/node/workbook/addWorksheet.test.ts | 2 +- .../v2/node/workbook/deleteWorkbook.test.ts | 2 +- .../test/v2/node/workbook/getAll.test.ts | 2 +- .../test/v2/node/worksheet/append.test.ts | 2 +- .../test/v2/node/worksheet/clear.test.ts | 2 +- .../v2/node/worksheet/deleteWorksheet.test.ts | 2 +- .../test/v2/node/worksheet/getAll.test.ts | 2 +- .../test/v2/node/worksheet/readRows.test.ts | 2 +- .../test/v2/node/worksheet/update.test.ts | 2 +- .../test/v2/node/worksheet/upsert.test.ts | 2 +- .../Microsoft/Excel/v1/GenericFunctions.ts | 11 +- .../Microsoft/Excel/v2/transport/index.ts | 11 +- .../GraphSecurity/GenericFunctions.ts | 14 ++- .../Microsoft/OneDrive/GenericFunctions.ts | 12 +- .../Microsoft/Outlook/v1/GenericFunctions.ts | 12 +- .../Microsoft/Outlook/v2/transport/index.ts | 22 ++-- .../Microsoft/Teams/v1/GenericFunctions.ts | 12 +- .../Microsoft/Teams/v2/transport/index.ts | 12 +- .../nodes/Microsoft/ToDo/GenericFunctions.ts | 12 +- .../nodes/Mindee/GenericFunctions.ts | 8 +- .../nodes-base/nodes/Misp/GenericFunctions.ts | 8 +- .../nodes/Mocean/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Mocean/Mocean.node.ts | 3 +- .../nodes/MondayCom/GenericFunctions.ts | 5 +- .../nodes/MonicaCrm/GenericFunctions.ts | 10 +- .../nodes/Msg91/GenericFunctions.ts | 10 +- packages/nodes-base/nodes/Msg91/Msg91.node.ts | 3 +- .../nodes-base/nodes/N8n/GenericFunctions.ts | 9 +- .../nodes-base/nodes/Nasa/GenericFunctions.ts | 17 ++- .../nodes/Netlify/GenericFunctions.ts | 10 +- .../nodes/NextCloud/GenericFunctions.ts | 19 ++-- .../nodes/NextCloud/NextCloud.node.ts | 11 +- .../nodes/NocoDB/GenericFunctions.ts | 10 +- .../nodes-base/nodes/NocoDB/NocoDB.node.ts | 3 +- .../nodes/Notion/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Odoo/GenericFunctions.ts | 5 +- packages/nodes-base/nodes/Odoo/Odoo.node.ts | 5 +- .../nodes/OneSimpleApi/GenericFunctions.ts | 14 ++- .../nodes/Onfleet/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Onfleet/Onfleet.node.ts | 4 +- .../nodes/OpenThesaurus/GenericFunctions.ts | 10 +- .../OpenWeatherMap/OpenWeatherMap.node.ts | 5 +- .../nodes/Orbit/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Oura/GenericFunctions.ts | 8 +- .../nodes/Paddle/GenericFunctions.ts | 10 +- .../nodes/PagerDuty/GenericFunctions.ts | 10 +- .../nodes/PayPal/GenericFunctions.ts | 10 +- .../nodes-base/nodes/PayPal/PayPal.node.ts | 4 +- .../nodes/Phantombuster/GenericFunctions.ts | 8 +- .../nodes/PhilipsHue/GenericFunctions.ts | 8 +- .../nodes/Pipedrive/GenericFunctions.ts | 10 +- .../nodes/Pipedrive/Pipedrive.node.ts | 3 +- .../nodes/Plivo/GenericFunctions.ts | 15 ++- .../nodes/PostHog/GenericFunctions.ts | 12 +- .../nodes/Postmark/GenericFunctions.ts | 8 +- .../nodes/ProfitWell/GenericFunctions.ts | 8 +- .../nodes/Pushbullet/GenericFunctions.ts | 14 +-- .../nodes/Pushcut/GenericFunctions.ts | 12 +- .../nodes/QuickBase/GenericFunctions.ts | 10 +- .../nodes/QuickBooks/GenericFunctions.ts | 11 +- .../nodes/Raindrop/GenericFunctions.ts | 8 +- .../nodes/Reddit/GenericFunctions.ts | 17 ++- .../nodes/Rocketchat/GenericFunctions.ts | 16 ++- .../nodes-base/nodes/Rundeck/RundeckApi.ts | 18 ++- .../nodes-base/nodes/S3/GenericFunctions.ts | 14 +-- .../nodes/Salesforce/GenericFunctions.ts | 16 +-- .../nodes/Salesforce/Salesforce.node.ts | 11 +- .../nodes/Salesmate/GenericFunctions.ts | 10 +- .../nodes/SeaTable/GenericFunctions.ts | 12 +- .../SecurityScorecard/GenericFunctions.ts | 8 +- .../nodes/Segment/GenericFunctions.ts | 7 +- .../nodes/SendGrid/GenericFunctions.ts | 10 +- .../nodes/SendGrid/SendGrid.node.ts | 5 +- .../nodes/Sendy/GenericFunctions.ts | 12 +- .../nodes/SentryIo/GenericFunctions.ts | 12 +- .../nodes/ServiceNow/GenericFunctions.ts | 12 +- .../nodes/Shopify/GenericFunctions.ts | 10 +- .../nodes/Signl4/GenericFunctions.ts | 14 ++- .../nodes/Slack/V1/GenericFunctions.ts | 12 +- .../nodes/Slack/V2/GenericFunctions.ts | 11 +- .../nodes/Sms77/GenericFunctions.ts | 15 ++- .../nodes/Splunk/GenericFunctions.ts | 8 +- .../nodes-base/nodes/Splunk/Splunk.node.ts | 4 +- .../nodes/Spontit/GenericFunctions.ts | 8 +- .../nodes/Spotify/GenericFunctions.ts | 21 ++-- .../nodes-base/nodes/Spotify/Spotify.node.ts | 3 +- .../nodes/Stackby/GenericFunction.ts | 10 +- .../nodes/Storyblok/GenericFunctions.ts | 14 +-- .../nodes/Strapi/GenericFunctions.ts | 14 +-- .../nodes-base/nodes/Strapi/Strapi.node.ts | 5 +- .../nodes/Strava/GenericFunctions.ts | 10 +- packages/nodes-base/nodes/Stripe/helpers.ts | 10 +- .../nodes/Supabase/GenericFunctions.ts | 10 +- .../nodes/SurveyMonkey/GenericFunctions.ts | 10 +- .../nodes/Taiga/GenericFunctions.ts | 13 ++- .../nodes/Tapfiliate/GenericFunctions.ts | 10 +- .../nodes/Telegram/GenericFunctions.ts | 8 +- .../nodes/Telegram/Telegram.node.ts | 3 +- .../nodes/TheHive/GenericFunctions.ts | 8 +- .../nodes-base/nodes/TheHive/TheHive.node.ts | 23 ++-- .../nodes/Todoist/GenericFunctions.ts | 10 +- .../nodes/Toggl/GenericFunctions.ts | 8 +- .../nodes/TravisCi/GenericFunctions.ts | 10 +- .../nodes/Trello/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Trello/Trello.node.ts | 3 +- .../nodes/Twake/GenericFunctions.ts | 16 ++- .../nodes/Twilio/GenericFunctions.ts | 14 ++- .../nodes-base/nodes/Twilio/Twilio.node.ts | 3 +- .../nodes/Twist/GenericFunctions.ts | 8 +- .../nodes/Twitter/V1/GenericFunctions.ts | 10 +- .../nodes/Twitter/V2/GenericFunctions.ts | 10 +- .../nodes/Typeform/GenericFunctions.ts | 10 +- .../nodes/UProc/GenericFunctions.ts | 4 +- .../UnleashedSoftware/GenericFunctions.ts | 10 +- .../nodes/Uplead/GenericFunctions.ts | 7 +- .../nodes/UptimeRobot/GenericFunctions.ts | 14 ++- .../nodes/UrlScanIo/GenericFunctions.ts | 6 +- .../Venafi/Datacenter/GenericFunctions.ts | 10 +- .../Venafi/ProtectCloud/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Vero/GenericFunctions.ts | 7 +- .../nodes/Vonage/GenericFunctions.ts | 9 +- .../nodes/Webflow/GenericFunctions.ts | 10 +- .../nodes/Wekan/GenericFunctions.ts | 8 +- packages/nodes-base/nodes/Wekan/Wekan.node.ts | 3 +- .../nodes/WooCommerce/GenericFunctions.ts | 9 +- .../nodes/Wordpress/GenericFunctions.ts | 10 +- .../nodes/Workable/GenericFunctions.ts | 8 +- .../nodes/Wufoo/GenericFunctions.ts | 8 +- .../nodes-base/nodes/Xero/GenericFunctions.ts | 10 +- .../nodes/Yourls/GenericFunctions.ts | 8 +- .../nodes/Zammad/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Zammad/Zammad.node.ts | 7 +- .../nodes/Zendesk/GenericFunctions.ts | 10 +- .../nodes-base/nodes/Zoho/GenericFunctions.ts | 12 +- .../nodes-base/nodes/Zoom/GenericFunctions.ts | 12 +- .../nodes/Zulip/GenericFunctions.ts | 10 +- packages/nodes-base/package.json | 1 - packages/workflow/src/Interfaces.ts | 82 +++++++++++--- pnpm-lock.yaml | 37 ------- 330 files changed, 1682 insertions(+), 1492 deletions(-) diff --git a/packages/@n8n/nodes-langchain/package.json b/packages/@n8n/nodes-langchain/package.json index cf866ce7e7..ccef21bfd7 100644 --- a/packages/@n8n/nodes-langchain/package.json +++ b/packages/@n8n/nodes-langchain/package.json @@ -117,7 +117,6 @@ "@types/express": "^4.17.6", "@types/html-to-text": "^9.0.1", "@types/json-schema": "^7.0.12", - "@types/request-promise-native": "~1.0.15", "@types/temp": "^0.9.1", "eslint-plugin-n8n-nodes-base": "^1.16.0", "gulp": "^4.0.2", diff --git a/packages/core/package.json b/packages/core/package.json index 5524aba898..66616505f9 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -40,7 +40,6 @@ "@types/express": "^4.17.6", "@types/lodash": "^4.14.195", "@types/mime-types": "^2.1.0", - "@types/request-promise-native": "~1.0.15", "@types/uuid": "^8.3.2", "@types/xml2js": "^0.4.11" }, diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index e7059bbee3..3129e964b8 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -18,10 +18,8 @@ import type { AxiosError, AxiosHeaders, AxiosPromise, - AxiosProxyConfig, AxiosRequestConfig, AxiosResponse, - Method, } from 'axios'; import axios from 'axios'; import crypto, { createHmac } from 'crypto'; @@ -77,6 +75,7 @@ import type { IOAuth2Options, IPairedItemData, IPollFunctions, + IRequestOptions, IRunExecutionData, ISourceData, ITaskData, @@ -121,8 +120,6 @@ import type { Token } from 'oauth-1.0a'; import clientOAuth1 from 'oauth-1.0a'; import path from 'path'; import { stringify } from 'qs'; -import type { OptionsWithUrl } from 'request'; -import type { OptionsWithUri, RequestPromiseOptions } from 'request-promise-native'; import { Readable } from 'stream'; import url, { URL, URLSearchParams } from 'url'; @@ -255,7 +252,7 @@ const getHostFromRequestObject = ( } }; -export async function parseRequestObject(requestObject: IDataObject) { +export async function parseRequestObject(requestObject: IRequestOptions) { // This function is a temporary implementation // That translates all http requests done via // the request library to axios directly @@ -369,28 +366,28 @@ export async function parseRequestObject(requestObject: IDataObject) { } if (requestObject.uri !== undefined) { - axiosConfig.url = requestObject.uri?.toString() as string; + axiosConfig.url = requestObject.uri?.toString(); } if (requestObject.url !== undefined) { - axiosConfig.url = requestObject.url?.toString() as string; + axiosConfig.url = requestObject.url?.toString(); } if (requestObject.baseURL !== undefined) { - axiosConfig.baseURL = requestObject.baseURL?.toString() as string; + axiosConfig.baseURL = requestObject.baseURL?.toString(); } if (requestObject.method !== undefined) { - axiosConfig.method = requestObject.method as Method; + axiosConfig.method = requestObject.method; } if (requestObject.qs !== undefined && Object.keys(requestObject.qs as object).length > 0) { - axiosConfig.params = requestObject.qs as IDataObject; + axiosConfig.params = requestObject.qs; } function hasArrayFormatOptions( - arg: IDataObject, - ): arg is IDataObject & { qsStringifyOptions: { arrayFormat: 'repeat' | 'brackets' } } { + arg: IRequestOptions, + ): arg is Required> { if ( typeof arg.qsStringifyOptions === 'object' && arg.qsStringifyOptions !== null && @@ -428,13 +425,13 @@ export async function parseRequestObject(requestObject: IDataObject) { if (requestObject.auth !== undefined) { // Check support for sendImmediately - if ((requestObject.auth as IDataObject).bearer !== undefined) { + if (requestObject.auth.bearer !== undefined) { axiosConfig.headers = Object.assign(axiosConfig.headers || {}, { // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - Authorization: `Bearer ${(requestObject.auth as IDataObject).bearer}`, + Authorization: `Bearer ${requestObject.auth.bearer}`, }); } else { - const authObj = requestObject.auth as IDataObject; + const authObj = requestObject.auth; // Request accepts both user/username and pass/password axiosConfig.auth = { username: (authObj.user || authObj.username) as string, @@ -506,7 +503,7 @@ export async function parseRequestObject(requestObject: IDataObject) { axiosConfig.httpsAgent = new Agent(agentOptions); if (requestObject.timeout !== undefined) { - axiosConfig.timeout = requestObject.timeout as number; + axiosConfig.timeout = requestObject.timeout; } if (requestObject.proxy !== undefined) { @@ -565,7 +562,7 @@ export async function parseRequestObject(requestObject: IDataObject) { } } } else { - axiosConfig.proxy = requestObject.proxy as AxiosProxyConfig; + axiosConfig.proxy = requestObject.proxy; } } @@ -664,12 +661,6 @@ function digestAuthAxiosConfig( return axiosConfig; } -type ConfigObject = { - auth?: { sendImmediately: boolean }; - resolveWithFullResponse?: boolean; - simple?: boolean; -}; - interface IContentType { type: string; parameters: { @@ -762,14 +753,14 @@ export async function proxyRequestToAxios( workflow: Workflow | undefined, additionalData: IWorkflowExecuteAdditionalData | undefined, node: INode | undefined, - uriOrObject: string | object, - options?: object, + uriOrObject: string | IRequestOptions, + options?: IRequestOptions, ): Promise { let axiosConfig: AxiosRequestConfig = { maxBodyLength: Infinity, maxContentLength: Infinity, }; - let configObject: ConfigObject & { uri?: string }; + let configObject: IRequestOptions; if (typeof uriOrObject === 'string') { configObject = { uri: uriOrObject, ...options }; } else { @@ -1247,10 +1238,10 @@ async function prepareBinaryData( } function applyPaginationRequestData( - requestData: OptionsWithUri, + requestData: IRequestOptions, paginationRequestData: PaginationOptions['request'], -): OptionsWithUri { - const preparedPaginationData: Partial = { +): IRequestOptions { + const preparedPaginationData: Partial = { ...paginationRequestData, uri: paginationRequestData.url, }; @@ -1269,13 +1260,13 @@ function applyPaginationRequestData( /** * Makes a request using OAuth data for authentication * - * @param {(OptionsWithUri | RequestPromiseOptions)} requestOptions + * @param {(IHttpRequestOptions | IRequestOptions)} requestOptions * */ export async function requestOAuth2( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUri | RequestPromiseOptions | IHttpRequestOptions, + requestOptions: IHttpRequestOptions | IRequestOptions, node: INode, additionalData: IWorkflowExecuteAdditionalData, oAuth2Options?: IOAuth2Options, @@ -1339,7 +1330,7 @@ export async function requestOAuth2( oAuth2Options?.tokenType || oauthTokenData.tokenType, ); - (requestOptions as OptionsWithUri).rejectUnauthorized = !credentials.ignoreSSLIssues; + (requestOptions as IRequestOptions).rejectUnauthorized = !credentials.ignoreSSLIssues; // Signs the request by adding authorization headers or query parameters depending // on the token-type used. @@ -1423,7 +1414,7 @@ export async function requestOAuth2( : oAuth2Options?.tokenExpiredStatusCode; return await this.helpers - .request(newRequestOptions) + .request(newRequestOptions as IRequestOptions) .then((response) => { const requestOptions = newRequestOptions as any; if ( @@ -1499,7 +1490,7 @@ export async function requestOAuth2( }); } - return await this.helpers.request(newRequestOptions); + return await this.helpers.request(newRequestOptions as IRequestOptions); } // Unknown error so simply throw it @@ -1513,7 +1504,7 @@ export async function requestOAuth2( export async function requestOAuth1( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUrl | OptionsWithUri | RequestPromiseOptions | IHttpRequestOptions, + requestOptions: IHttpRequestOptions | IRequestOptions, isN8nRequest = false, ) { const credentials = await this.getCredentials(credentialsType); @@ -1560,25 +1551,24 @@ export async function requestOAuth1( requestOptions.data = { ...requestOptions.qs, ...requestOptions.form }; // Fixes issue that OAuth1 library only works with "url" property and not with "uri" - // @ts-expect-error @TECH_DEBT: Remove request library - if (requestOptions.uri && !requestOptions.url) { - // @ts-expect-error @TECH_DEBT: Remove request library + if ('uri' in requestOptions && !requestOptions.url) { requestOptions.url = requestOptions.uri; - // @ts-expect-error @TECH_DEBT: Remove request library delete requestOptions.uri; } requestOptions.headers = oauth.toHeader( oauth.authorize(requestOptions as unknown as clientOAuth1.RequestOptions, token), - ); + ) as unknown as Record; if (isN8nRequest) { return await this.helpers.httpRequest(requestOptions as IHttpRequestOptions); } - return await this.helpers.request(requestOptions).catch(async (error: IResponseError) => { - // Unknown error so simply throw it - throw error; - }); + return await this.helpers + .request(requestOptions as IRequestOptions) + .catch(async (error: IResponseError) => { + // Unknown error so simply throw it + throw error; + }); } export async function httpRequestWithAuthentication( @@ -1776,7 +1766,7 @@ export function normalizeItems( export async function requestWithAuthentication( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUri | RequestPromiseOptions, + requestOptions: IRequestOptions, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, @@ -1831,14 +1821,14 @@ export async function requestWithAuthentication( Object.assign(credentialsDecrypted, data); } - requestOptions = await additionalData.credentialsHelper.authenticate( + requestOptions = (await additionalData.credentialsHelper.authenticate( credentialsDecrypted, credentialsType, requestOptions as IHttpRequestOptions, workflow, node, - ); - return await proxyRequestToAxios(workflow, additionalData, node, requestOptions as IDataObject); + )) as IRequestOptions; + return await proxyRequestToAxios(workflow, additionalData, node, requestOptions); } catch (error) { try { if (credentialsDecrypted !== undefined) { @@ -1855,20 +1845,15 @@ export async function requestWithAuthentication( // make the updated property in the credentials // available to the authenticate method Object.assign(credentialsDecrypted, data); - requestOptions = await additionalData.credentialsHelper.authenticate( + requestOptions = (await additionalData.credentialsHelper.authenticate( credentialsDecrypted, credentialsType, requestOptions as IHttpRequestOptions, workflow, node, - ); + )) as IRequestOptions; // retry the request - return await proxyRequestToAxios( - workflow, - additionalData, - node, - requestOptions as IDataObject, - ); + return await proxyRequestToAxios(workflow, additionalData, node, requestOptions); } } throw error; @@ -2849,7 +2834,7 @@ const getRequestHelperFunctions = ( httpRequest, async requestWithAuthenticationPaginated( this: IExecuteFunctions, - requestOptions: OptionsWithUri, + requestOptions: IRequestOptions, itemIndex: number, paginationOptions: PaginationOptions, credentialsType?: string, @@ -3093,7 +3078,7 @@ const getRequestHelperFunctions = ( async requestOAuth1( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUrl | RequestPromiseOptions, + requestOptions: IRequestOptions, ): Promise { return await requestOAuth1.call(this, credentialsType, requestOptions); }, @@ -3101,7 +3086,7 @@ const getRequestHelperFunctions = ( async requestOAuth2( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUri | RequestPromiseOptions, + requestOptions: IRequestOptions, oAuth2Options?: IOAuth2Options, ): Promise { return await requestOAuth2.call( diff --git a/packages/nodes-base/credentials/Aws.credentials.ts b/packages/nodes-base/credentials/Aws.credentials.ts index 6b5620384c..23171f742f 100644 --- a/packages/nodes-base/credentials/Aws.credentials.ts +++ b/packages/nodes-base/credentials/Aws.credentials.ts @@ -8,9 +8,9 @@ import type { IDataObject, IHttpRequestOptions, INodeProperties, + IRequestOptions, } from 'n8n-workflow'; import { isObjectEmpty } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; export const regions = [ { @@ -286,16 +286,16 @@ export class Aws implements ICredentialType { let body = requestOptions.body; let region = credentials.region; let query = requestOptions.qs?.query as IDataObject; - // ! Workaround as we still use the OptionsWithUri interface which uses uri instead of url + // ! Workaround as we still use the IRequestOptions interface which uses uri instead of url // ! To change when we replace the interface with IHttpRequestOptions - const requestWithUri = requestOptions as unknown as OptionsWithUri; + const requestWithUri = requestOptions as unknown as IRequestOptions; if (requestWithUri.uri) { - requestOptions.url = requestWithUri.uri as string; + requestOptions.url = requestWithUri.uri; endpoint = new URL(requestOptions.url); if (service === 'sts') { try { if (requestWithUri.qs?.Action !== 'GetCallerIdentity') { - query = requestWithUri.qs; + query = requestWithUri.qs as IDataObject; } else { endpoint.searchParams.set('Action', 'GetCallerIdentity'); endpoint.searchParams.set('Version', '2011-06-15'); diff --git a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts index 14af98492b..a9545ffe80 100644 --- a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts @@ -1,6 +1,10 @@ -import type { IDataObject, IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-workflow'; - -import type { OptionsWithUri } from 'request'; +import type { + IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, +} from 'n8n-workflow'; import flow from 'lodash/flow'; import omit from 'lodash/omit'; @@ -17,12 +21,12 @@ import type { export async function actionNetworkApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, @@ -59,7 +63,7 @@ const toItemsKey = (endpoint: string) => { export async function handleListing( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -77,7 +81,13 @@ export async function handleListing( const itemsKey = toItemsKey(endpoint); do { - responseData = await actionNetworkApiRequest.call(this, method, endpoint, body, qs); + responseData = await actionNetworkApiRequest.call( + this, + method as IHttpRequestMethods, + endpoint, + body, + qs, + ); const items = responseData._embedded[itemsKey]; returnData.push(...(items as IDataObject[])); diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 404aebb8b0..989f28478a 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -6,6 +6,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -317,7 +318,7 @@ export class ActiveCampaign implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; let returnAll = false; let dataKey: string | undefined; diff --git a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts index 5350d7d17b..8aa041c3d4 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts @@ -5,11 +5,11 @@ import type { ILoadOptionsFunctions, INodeProperties, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - export interface IProduct { fields: { item?: object[]; @@ -22,7 +22,7 @@ export interface IProduct { */ export async function activeCampaignApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, @@ -34,7 +34,7 @@ export async function activeCampaignApiRequest( query = {}; } - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, qs: query, @@ -75,7 +75,7 @@ export async function activeCampaignApiRequest( */ export async function activeCampaignApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts b/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts index 03453268c2..ae68762998 100644 --- a/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts @@ -1,9 +1,10 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -11,7 +12,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function acuitySchedulingApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, @@ -20,7 +21,7 @@ export async function acuitySchedulingApiRequest( ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts index 15bcf5480f..54ece184d5 100644 --- a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, @@ -7,12 +5,14 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { BINARY_ENCODING, NodeApiError } from 'n8n-workflow'; export async function affinityApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, query: IDataObject = {}, @@ -25,7 +25,7 @@ export async function affinityApiRequest( const endpoint = 'https://api.affinity.co'; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', Authorization: `Basic ${Buffer.from(apiKey).toString(BINARY_ENCODING)}`, @@ -53,7 +53,7 @@ export async function affinityApiRequest( export async function affinityApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts index eaa68d6393..69b725adf2 100644 --- a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -15,7 +15,7 @@ import type { IFilterRules, ISearchConditions } from './FilterInterface'; export async function agileCrmApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, query: IDataObject = {}, @@ -23,7 +23,7 @@ export async function agileCrmApiRequest( sendAsForm?: boolean, ): Promise { const credentials = await this.getCredentials('agileCrmApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: { Accept: 'application/json', @@ -56,7 +56,7 @@ export async function agileCrmApiRequest( export async function agileCrmApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, query: IDataObject = {}, @@ -95,7 +95,7 @@ export async function agileCrmApiRequestAllItems( export async function agileCrmApiRequestUpdate( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method = 'PUT', + method: IHttpRequestMethods = 'PUT', endpoint?: string, body: any = {}, _query: IDataObject = {}, @@ -103,7 +103,7 @@ export async function agileCrmApiRequestUpdate( ): Promise { const credentials = await this.getCredentials('agileCrmApi'); const baseUri = `https://${credentials.subdomain}.agilecrm.com/dev/`; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: { Accept: 'application/json', diff --git a/packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts b/packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts index aebef1c310..396db4c9e4 100644 --- a/packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts +++ b/packages/nodes-base/nodes/Airtable/v1/AirtableV1.node.ts @@ -6,6 +6,7 @@ import type { INodeType, INodeTypeDescription, INodeTypeBaseDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -569,7 +570,7 @@ export class AirtableV1 implements INodeType { let returnAll = false; let endpoint = ''; - let requestMethod = ''; + let requestMethod: IHttpRequestMethods; const body: IDataObject = {}; const qs: IDataObject = {}; diff --git a/packages/nodes-base/nodes/Airtable/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/v1/GenericFunctions.ts index d95c8b45fe..c4e7c4f3d3 100644 --- a/packages/nodes-base/nodes/Airtable/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/v1/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IBinaryKeyData, IDataObject, @@ -8,6 +6,8 @@ import type { ILoadOptionsFunctions, INodeExecutionData, IPairedItemData, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; interface IAttachment { @@ -28,7 +28,7 @@ export interface IRecord { */ export async function apiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, query?: IDataObject, @@ -42,7 +42,7 @@ export async function apiRequest( // it as query string. // query.api_key = credentials.apiKey; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, body, @@ -71,7 +71,7 @@ export async function apiRequest( */ export async function apiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/Airtable/v2/transport/index.ts b/packages/nodes-base/nodes/Airtable/v2/transport/index.ts index 591ce29deb..95d2c3c1f8 100644 --- a/packages/nodes-base/nodes/Airtable/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Airtable/v2/transport/index.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IBinaryKeyData, IDataObject, @@ -8,6 +6,8 @@ import type { ILoadOptionsFunctions, INodeExecutionData, IPairedItemData, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { ApplicationError } from 'n8n-workflow'; import type { IAttachment, IRecord } from '../helpers/interfaces'; @@ -19,7 +19,7 @@ import { flattenOutput } from '../helpers/utils'; */ export async function apiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query?: IDataObject, @@ -28,7 +28,7 @@ export async function apiRequest( ) { query = query || {}; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, body, @@ -58,7 +58,7 @@ export async function apiRequest( */ export async function apiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body?: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts b/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts index 49f6be68b1..e099412bca 100644 --- a/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts @@ -1,16 +1,20 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + ILoadOptionsFunctions, + JsonObject, + IRequestOptions, + IHttpRequestMethods, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function apiTemplateIoApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs = {}, body = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'user-agent': 'n8n', Accept: 'application/json', diff --git a/packages/nodes-base/nodes/Automizy/GenericFunctions.ts b/packages/nodes-base/nodes/Automizy/GenericFunctions.ts index 26de35ce15..0e92d09333 100644 --- a/packages/nodes-base/nodes/Automizy/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Automizy/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function automizyApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -19,7 +19,7 @@ export async function automizyApiRequest( ): Promise { const credentials = (await this.getCredentials('automizyApi')) as IDataObject; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.apiToken}`, }, @@ -50,7 +50,7 @@ export async function automizyApiRequest( export async function automizyApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts b/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts index daba7d5506..fedcd86ebb 100644 --- a/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts +++ b/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts @@ -6,6 +6,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { autopilotApiRequest, autopilotApiRequestAllItems } from './GenericFunctions'; @@ -228,7 +229,7 @@ export class Autopilot implements INodeType { const contactId = this.getNodeParameter('contactId', i) as string; - const method: { [key: string]: string } = { + const method: { [key: string]: IHttpRequestMethods } = { add: 'POST', remove: 'DELETE', exist: 'GET', diff --git a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts index 7d448c560f..f6387d27e9 100644 --- a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, @@ -7,14 +5,15 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function autopilotApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, - body: any = {}, query: IDataObject = {}, uri?: string, @@ -26,7 +25,7 @@ export async function autopilotApiRequest( const endpoint = 'https://api2.autopilothq.com/v1'; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', autopilotapikey: apiKey, @@ -54,7 +53,7 @@ export async function autopilotApiRequest( export async function autopilotApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts index aa9ad44fbe..bff183fcee 100644 --- a/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts @@ -8,13 +8,14 @@ import type { IWebhookFunctions, IHttpRequestOptions, JsonObject, + IHttpRequestMethods, } from 'n8n-workflow'; import { jsonParse, NodeApiError } from 'n8n-workflow'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer, query: IDataObject = {}, @@ -45,7 +46,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, @@ -63,7 +64,7 @@ export async function awsApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts index 65896effb4..7f327518a0 100644 --- a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts @@ -6,12 +6,13 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, IHttpRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -35,7 +36,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -51,7 +52,7 @@ export async function awsApiRequestREST( export async function awsApiRequestSOAP( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts index eb1a6df226..dc79c12dc2 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts @@ -6,6 +6,7 @@ import type { IWebhookFunctions, IHttpRequestOptions, INodeExecutionData, + IHttpRequestMethods, } from 'n8n-workflow'; import { ApplicationError, deepCopy } from 'n8n-workflow'; @@ -14,7 +15,7 @@ import type { IRequestBody } from './types'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: object | IRequestBody, headers?: object, @@ -68,7 +69,7 @@ export async function awsApiRequest( export async function awsApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: IRequestBody, headers?: object, diff --git a/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts index b7c48a06d1..51a88f61ba 100644 --- a/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts @@ -10,13 +10,14 @@ import type { IWebhookFunctions, IHttpRequestOptions, JsonObject, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer, query: IDataObject = {}, @@ -49,7 +50,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, @@ -78,7 +79,7 @@ export async function awsApiRequestREST( export async function awsApiRequestSOAP( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer, query: IDataObject = {}, @@ -115,7 +116,7 @@ export async function awsApiRequestSOAPAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Aws/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/GenericFunctions.ts index 7611eaab78..5c65217e9b 100644 --- a/packages/nodes-base/nodes/Aws/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/GenericFunctions.ts @@ -7,13 +7,14 @@ import type { IWebhookFunctions, IHttpRequestOptions, JsonObject, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -41,7 +42,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -57,7 +58,7 @@ export async function awsApiRequestREST( export async function awsApiRequestSOAP( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, diff --git a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts index 4b8ce45826..b0992162ca 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts @@ -9,6 +9,7 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, IHttpRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { pascalCase } from 'change-case'; @@ -16,7 +17,7 @@ import { pascalCase } from 'change-case'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer | IDataObject, _query: IDataObject = {}, @@ -47,7 +48,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, @@ -76,7 +77,7 @@ export async function awsApiRequestREST( export async function awsApiRequestSOAP( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer | IDataObject, query: IDataObject = {}, @@ -113,7 +114,7 @@ export async function awsApiRequestSOAPAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Aws/S3/V1/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/S3/V1/GenericFunctions.ts index 181fd6f60d..06700d283d 100644 --- a/packages/nodes-base/nodes/Aws/S3/V1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/S3/V1/GenericFunctions.ts @@ -9,12 +9,13 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, IHttpRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer, query: IDataObject = {}, @@ -45,7 +46,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, @@ -74,7 +75,7 @@ export async function awsApiRequestREST( export async function awsApiRequestSOAP( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer, query: IDataObject = {}, @@ -111,7 +112,7 @@ export async function awsApiRequestSOAPAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Aws/S3/V2/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/S3/V2/GenericFunctions.ts index 908c1b7b58..1ad21232d8 100644 --- a/packages/nodes-base/nodes/Aws/S3/V2/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/S3/V2/GenericFunctions.ts @@ -9,12 +9,13 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, IHttpRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer | any, query: IDataObject = {}, @@ -43,7 +44,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer | any, query: IDataObject = {}, @@ -83,7 +84,7 @@ export async function awsApiRequestRESTAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts index 382661f708..b71053bd28 100644 --- a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts @@ -8,6 +8,7 @@ import type { IWebhookFunctions, IHttpRequestOptions, JsonObject, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -16,7 +17,7 @@ import get from 'lodash/get'; export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -45,7 +46,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -61,7 +62,7 @@ export async function awsApiRequestREST( export async function awsApiRequestSOAP( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -85,7 +86,7 @@ export async function awsApiRequestSOAPAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts index 003eaf40b6..663c82b54e 100644 --- a/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts @@ -3,8 +3,6 @@ import { URL } from 'url'; import type { Request } from 'aws4'; import { sign } from 'aws4'; -import type { OptionsWithUri } from 'request'; - import { parseString } from 'xml2js'; import type { @@ -16,6 +14,8 @@ import type { IWebhookFunctions, IHttpRequestOptions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -37,7 +37,7 @@ function getEndpointForService( export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -77,7 +77,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -93,7 +93,7 @@ export async function awsApiRequestREST( export async function awsApiRequestSOAP( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -165,7 +165,7 @@ export async function validateCredentials( sign(signOpts, securityHeaders); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: signOpts.headers, method: 'POST', uri: endpoint.href, diff --git a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts index c94b833ec7..05faeb8a83 100644 --- a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts @@ -3,14 +3,14 @@ import { URL } from 'url'; import type { Request } from 'aws4'; import { sign } from 'aws4'; -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -36,7 +36,7 @@ function getEndpointForService( export async function awsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -58,7 +58,7 @@ export async function awsApiRequest( sign(signOpts, securityHeaders); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: signOpts.headers, method, uri: endpoint.href, @@ -75,7 +75,7 @@ export async function awsApiRequest( export async function awsApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, headers?: object, @@ -92,7 +92,7 @@ export async function awsApiRequestRESTAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts b/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts index e20d26a8d7..1a993e98c9 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts @@ -4,11 +4,10 @@ import type { IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUrl } from 'request'; - /** * Make an API request to Mattermost */ @@ -29,7 +28,7 @@ export async function apiRequest( //set-up uri const uri = `https://api.bamboohr.com/api/gateway.php/${subdomain}/v1/${endpoint}`; - const options: OptionsWithUrl = { + const options: IRequestOptions = { method, body, qs: query, diff --git a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts index 82874197aa..0e48b58d83 100644 --- a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, @@ -7,6 +5,8 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -14,7 +14,7 @@ import { snakeCase } from 'change-case'; export async function bannerbearApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -24,7 +24,7 @@ export async function bannerbearApiRequest( ): Promise { const credentials = await this.getCredentials('bannerbearApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Accept: 'application/json', Authorization: `Bearer ${credentials.apiKey}`, diff --git a/packages/nodes-base/nodes/Baserow/GenericFunctions.ts b/packages/nodes-base/nodes/Baserow/GenericFunctions.ts index b4b71f2c0e..8e30c5c148 100644 --- a/packages/nodes-base/nodes/Baserow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Baserow/GenericFunctions.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -15,7 +15,7 @@ import type { Accumulator, BaserowCredentials, LoadedResource } from './types'; */ export async function baserowApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, jwtToken: string, body: IDataObject = {}, @@ -23,7 +23,7 @@ export async function baserowApiRequest( ) { const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `JWT ${jwtToken}`, }, @@ -54,7 +54,7 @@ export async function baserowApiRequest( */ export async function baserowApiRequestAllItems( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, jwtToken: string, body: IDataObject, @@ -90,7 +90,7 @@ export async function getJwtToken( this: IExecuteFunctions | ILoadOptionsFunctions, { username, password, host }: BaserowCredentials, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'POST', body: { username, diff --git a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts index ec9c7c5059..7e2701b701 100644 --- a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts @@ -1,24 +1,24 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, IHookFunctions, IWebhookFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; const BEEMINDER_URI = 'https://www.beeminder.com/api/v1'; export async function beeminderApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, query: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs: query, @@ -39,7 +39,7 @@ export async function beeminderApiRequest( export async function beeminderApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts b/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts index 82581b77ee..e0e6a13778 100644 --- a/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts +++ b/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IHookFunctions, IWebhookFunctions, @@ -12,6 +10,7 @@ import type { INodeType, INodeTypeDescription, IWebhookResponseData, + IRequestOptions, } from 'n8n-workflow'; import { bitbucketApiRequest, bitbucketApiRequestAllItems } from './GenericFunctions'; @@ -145,7 +144,7 @@ export class BitbucketTrigger implements INodeType { ): Promise { const credentials = credential.data; - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'GET', auth: { user: credentials!.username as string, diff --git a/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts b/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts index b9c98c4c2d..3281757d07 100644 --- a/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts @@ -1,16 +1,17 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function bitbucketApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -19,7 +20,7 @@ export async function bitbucketApiRequest( option: IDataObject = {}, ): Promise { const credentials = await this.getCredentials('bitbucketApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, auth: { user: credentials.username as string, @@ -49,7 +50,7 @@ export async function bitbucketApiRequest( export async function bitbucketApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts index 321c5800e7..daadfdd508 100644 --- a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function bitlyApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function bitlyApiRequest( option: IDataObject = {}, ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0) as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: {}, method, qs, @@ -56,7 +56,7 @@ export async function bitlyApiRequest( export async function bitlyApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts index e91cba2e32..0bb12eac99 100644 --- a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts @@ -1,14 +1,14 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodePropertyOptions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Return the access token URL based on the user's environment. */ @@ -34,14 +34,14 @@ async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { */ export async function bitwardenApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, body: IDataObject, token: string, ): Promise { const baseUrl = await getBaseUrl.call(this); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'user-agent': 'n8n', Authorization: `Bearer ${token}`, @@ -77,7 +77,7 @@ export async function getAccessToken( ): Promise { const credentials = await this.getCredentials('bitwardenApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, @@ -109,7 +109,7 @@ export async function getAccessToken( export async function handleGetAll( this: IExecuteFunctions, i: number, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, body: IDataObject, diff --git a/packages/nodes-base/nodes/Box/GenericFunctions.ts b/packages/nodes-base/nodes/Box/GenericFunctions.ts index ea77a8edc7..f768a21765 100644 --- a/packages/nodes-base/nodes/Box/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Box/GenericFunctions.ts @@ -1,18 +1,18 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, IOAuth2Options, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function boxApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function boxApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -51,7 +51,7 @@ export async function boxApiRequest( export async function boxApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts b/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts index a7472f0a02..6a18a4579f 100644 --- a/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function brandfetchApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function brandfetchApiRequest( ): Promise { try { const credentials = await this.getCredentials('brandfetchApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'x-api-key': credentials.apiKey, }, diff --git a/packages/nodes-base/nodes/Brevo/GenericFunctions.ts b/packages/nodes-base/nodes/Brevo/GenericFunctions.ts index 55a9958cc8..d43f3e8bfd 100644 --- a/packages/nodes-base/nodes/Brevo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Brevo/GenericFunctions.ts @@ -2,11 +2,11 @@ import type { IExecuteSingleFunctions, IHookFunctions, IHttpRequestOptions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; import { jsonParse, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import MailComposer from 'nodemailer/lib/mail-composer'; export namespace BrevoNode { type ValidEmailFields = { to: string } | { sender: string } | { cc: string } | { bcc: string }; @@ -311,7 +311,7 @@ export namespace BrevoWebhookApi { export const fetchWebhooks = async (ref: IHookFunctions, type: string): Promise => { const endpoint = `${baseURL}/webhooks?type=${type}`; - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'GET', headers: { Accept: 'application/json', @@ -336,7 +336,7 @@ export namespace BrevoWebhookApi { ): Promise => { const endpoint = `${baseURL}/webhooks`; - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'POST', headers: { Accept: 'application/json', @@ -362,7 +362,7 @@ export namespace BrevoWebhookApi { const endpoint = `${baseURL}/webhooks/${webhookId}`; const body = {}; - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'DELETE', headers: { Accept: 'application/json', diff --git a/packages/nodes-base/nodes/Bubble/GenericFunctions.ts b/packages/nodes-base/nodes/Bubble/GenericFunctions.ts index 3128e91ee9..46927492e9 100644 --- a/packages/nodes-base/nodes/Bubble/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bubble/GenericFunctions.ts @@ -4,17 +4,17 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Make an authenticated API request to Bubble. */ export async function bubbleApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, qs: IDataObject, @@ -32,7 +32,7 @@ export async function bubbleApiRequest( const rootUrl = hosting === 'bubbleHosted' ? `https://${appName}.bubbleapps.io` : domain; const urlSegment = environment === 'development' ? '/version-test/api/1.1' : '/api/1.1'; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'user-agent': 'n8n', Authorization: `Bearer ${apiToken}`, @@ -64,7 +64,7 @@ export async function bubbleApiRequest( */ export async function bubbleApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, qs: IDataObject, diff --git a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts index b94dd6220d..4befbb5cee 100644 --- a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, @@ -8,6 +6,8 @@ import type { ILoadOptionsFunctions, IHookFunctions, IWebhookFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; export function getAuthenticationType(data: string): 'accessToken' | 'apiKey' { @@ -18,7 +18,7 @@ export function getAuthenticationType(data: string): 'accessToken' | 'apiKey' { export async function calendlyApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -41,7 +41,7 @@ export async function calendlyApiRequest( endpoint = 'https://calendly.com/api/v1'; } - let options: OptionsWithUri = { + let options: IRequestOptions = { headers, method, body, @@ -72,7 +72,7 @@ export async function validateCredentials( const authenticationType = getAuthenticationType(apiKey); - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'GET', uri: '', json: true, diff --git a/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts b/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts index 62dd0be0a9..e8874663aa 100644 --- a/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts +++ b/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts @@ -6,6 +6,8 @@ import type { INodeTypeDescription, JsonObject, NodeParameterValue, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -463,7 +465,7 @@ export class Chargebee implements INodeType { const resource = this.getNodeParameter('resource', i); const operation = this.getNodeParameter('operation', i); - let requestMethod = 'GET'; + let requestMethod: IHttpRequestMethods = 'GET'; let endpoint = ''; body = {}; qs = {}; @@ -589,7 +591,7 @@ export class Chargebee implements INodeType { pass: '', }, json: true, - }; + } satisfies IRequestOptions; let responseData; diff --git a/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts b/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts index 661f5c5336..370981bebe 100644 --- a/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function circleciApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function circleciApiRequest( option: IDataObject = {}, ): Promise { const credentials = await this.getCredentials('circleCiApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Circle-Token': credentials.apiKey, Accept: 'application/json', @@ -49,7 +49,7 @@ export async function circleciApiRequest( export async function circleciApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts index dac7862b00..88d2037430 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts @@ -1,13 +1,14 @@ import { createHash } from 'crypto'; -import type { OptionsWithUri } from 'request'; import type { ICredentialDataDecryptedObject, IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeProperties, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -17,7 +18,7 @@ import upperFirst from 'lodash/upperFirst'; export async function webexApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -25,7 +26,7 @@ export async function webexApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { method, body, qs, @@ -54,7 +55,7 @@ export async function webexApiRequest( export async function webexApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts b/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts index d4b9aad4c7..4b9e0ea9b5 100644 --- a/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, @@ -7,12 +5,14 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function citrixADCApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -21,7 +21,7 @@ export async function citrixADCApiRequest( ): Promise { const { url } = (await this.getCredentials('citrixAdcApi')) as { url: string }; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts index 5c3dc9cea7..95a45b65af 100644 --- a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function clearbitApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, api: string, resource: string, @@ -21,7 +21,7 @@ export async function clearbitApiRequest( option: IDataObject = {}, ): Promise { const credentials = await this.getCredentials('clearbitApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.apiKey}` }, method, qs, diff --git a/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts b/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts index a17f77c4de..21974d6a08 100644 --- a/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, @@ -8,12 +6,14 @@ import type { IWebhookFunctions, IOAuth2Options, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function clickupApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function clickupApiRequest( uri?: string, _option: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -58,7 +58,7 @@ export async function clickupApiRequest( export async function clickupApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Clockify/GenericFunctions.ts b/packages/nodes-base/nodes/Clockify/GenericFunctions.ts index 0ae788c7a9..0a5a09bfff 100644 --- a/packages/nodes-base/nodes/Clockify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clockify/GenericFunctions.ts @@ -1,15 +1,15 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IPollFunctions, IDataObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; export async function clockifyApiRequest( this: ILoadOptionsFunctions | IPollFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -19,7 +19,7 @@ export async function clockifyApiRequest( ): Promise { const BASE_URL = 'https://api.clockify.me/api/v1'; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -35,7 +35,7 @@ export async function clockifyApiRequest( export async function clockifyApiRequestAllItems( this: IExecuteFunctions | IPollFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts b/packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts index ea764fcaf8..0ad5801325 100644 --- a/packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts @@ -1,24 +1,24 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, IPollFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function cloudflareApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, @@ -42,7 +42,7 @@ export async function cloudflareApiRequest( export async function cloudflareApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts b/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts index 81a2d6e62d..07955905f2 100644 --- a/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts @@ -20,7 +20,7 @@ export async function createCollectionEntry( }; } - return await cockpitApiRequest.call(this, 'post', `/collections/save/${resourceName}`, body); + return await cockpitApiRequest.call(this, 'POST', `/collections/save/${resourceName}`, body); } export async function getAllCollectionEntries( @@ -76,7 +76,7 @@ export async function getAllCollectionEntries( body.lang = options.language as string; } - return await cockpitApiRequest.call(this, 'post', `/collections/get/${resourceName}`, body); + return await cockpitApiRequest.call(this, 'POST', `/collections/get/${resourceName}`, body); } export async function getAllCollectionNames( diff --git a/packages/nodes-base/nodes/Cockpit/FormFunctions.ts b/packages/nodes-base/nodes/Cockpit/FormFunctions.ts index 28ec4834bc..1b48287439 100644 --- a/packages/nodes-base/nodes/Cockpit/FormFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/FormFunctions.ts @@ -11,5 +11,5 @@ export async function submitForm( form, }; - return await cockpitApiRequest.call(this, 'post', `/forms/submit/${resourceName}`, body); + return await cockpitApiRequest.call(this, 'POST', `/forms/submit/${resourceName}`, body); } diff --git a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts index e950dd7f34..f6b30fb9ca 100644 --- a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts @@ -1,15 +1,16 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { jsonParse, NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; export async function cockpitApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -17,7 +18,7 @@ export async function cockpitApiRequest( option: IDataObject = {}, ): Promise { const credentials = await this.getCredentials('cockpitApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', diff --git a/packages/nodes-base/nodes/Cockpit/SingletonFunctions.ts b/packages/nodes-base/nodes/Cockpit/SingletonFunctions.ts index 9261d0e4cf..464f1f2bad 100644 --- a/packages/nodes-base/nodes/Cockpit/SingletonFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/SingletonFunctions.ts @@ -5,7 +5,7 @@ export async function getSingleton( this: IExecuteFunctions | ILoadOptionsFunctions, resourceName: string, ): Promise { - return await cockpitApiRequest.call(this, 'get', `/singletons/get/${resourceName}`); + return await cockpitApiRequest.call(this, 'GET', `/singletons/get/${resourceName}`); } export async function getAllSingletonNames( diff --git a/packages/nodes-base/nodes/Coda/GenericFunctions.ts b/packages/nodes-base/nodes/Coda/GenericFunctions.ts index e2cdf6b8a8..b889e7dafa 100644 --- a/packages/nodes-base/nodes/Coda/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Coda/GenericFunctions.ts @@ -1,15 +1,16 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function codaApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -19,7 +20,7 @@ export async function codaApiRequest( ): Promise { const credentials = await this.getCredentials('codaApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.accessToken}`, 'User-Agent': 'n8n', @@ -49,7 +50,7 @@ export async function codaApiRequest( export async function codaApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts b/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts index b3d40454c0..141ed62851 100644 --- a/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function coinGeckoApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -18,7 +18,7 @@ export async function coinGeckoApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -47,7 +47,7 @@ export async function coinGeckoApiRequest( export async function coinGeckoRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Contentful/GenericFunctions.ts b/packages/nodes-base/nodes/Contentful/GenericFunctions.ts index 273f5d165e..270aadc448 100644 --- a/packages/nodes-base/nodes/Contentful/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Contentful/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function contentfulApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -22,7 +22,7 @@ export async function contentfulApiRequest( const source = this.getNodeParameter('source', 0) as string; const isPreview = source === 'previewApi'; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, qs, body, @@ -46,7 +46,7 @@ export async function contentfulApiRequest( export async function contentfulApiRequestAllItems( this: ILoadOptionsFunctions | IExecuteFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts index 66d1650e74..68569e4c86 100644 --- a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, IHookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function convertKitApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -21,7 +21,7 @@ export async function convertKitApiRequest( ): Promise { const credentials = await this.getCredentials('convertKitApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/Copper/GenericFunctions.ts b/packages/nodes-base/nodes/Copper/GenericFunctions.ts index fce3bde9c0..2ffd1ca7cf 100644 --- a/packages/nodes-base/nodes/Copper/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Copper/GenericFunctions.ts @@ -1,13 +1,13 @@ import { createHash } from 'crypto'; -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -28,7 +28,7 @@ import type { */ export async function copperApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -37,7 +37,7 @@ export async function copperApiRequest( ) { const credentials = (await this.getCredentials('copperApi')) as { apiKey: string; email: string }; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'X-PW-AccessToken': credentials.apiKey, 'X-PW-Application': 'developer_api', @@ -147,7 +147,7 @@ export const adjustTaskFields = flow(adjustLeadFields, adjustProjectIds); */ export async function copperApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -173,7 +173,7 @@ export async function copperApiRequestAllItems( */ export async function handleListing( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject = {}, body: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts index 193cf51599..45f4105a10 100644 --- a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, } from 'n8n-workflow'; import moment from 'moment-timezone'; export async function cortexApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function cortexApiRequest( ): Promise { const credentials = await this.getCredentials('cortexApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: {}, method, qs: query, diff --git a/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts b/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts index 0ff12804bd..dd6e356d95 100644 --- a/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts @@ -11,7 +11,7 @@ import get from 'lodash/get'; export async function customerIoApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, baseApi?: string, @@ -22,7 +22,7 @@ export async function customerIoApiRequest( headers: { 'Content-Type': 'application/json', }, - method: method as IHttpRequestMethods, + method, body, url: '', json: true, diff --git a/packages/nodes-base/nodes/DeepL/GenericFunctions.ts b/packages/nodes-base/nodes/DeepL/GenericFunctions.ts index 5d8db92eb2..649096fc00 100644 --- a/packages/nodes-base/nodes/DeepL/GenericFunctions.ts +++ b/packages/nodes-base/nodes/DeepL/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function deepLApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -22,7 +22,7 @@ export async function deepLApiRequest( const credentials = await this.getCredentials('deepLApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, diff --git a/packages/nodes-base/nodes/Demio/GenericFunctions.ts b/packages/nodes-base/nodes/Demio/GenericFunctions.ts index 5304b67f52..17c113be7f 100644 --- a/packages/nodes-base/nodes/Demio/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Demio/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function demioApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function demioApiRequest( ): Promise { try { const credentials = await this.getCredentials('demioApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Api-Key': credentials.apiKey, 'Api-Secret': credentials.apiSecret, diff --git a/packages/nodes-base/nodes/Dhl/GenericFunctions.ts b/packages/nodes-base/nodes/Dhl/GenericFunctions.ts index 6f63f7b9af..1a062fb12a 100644 --- a/packages/nodes-base/nodes/Dhl/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Dhl/GenericFunctions.ts @@ -1,19 +1,19 @@ -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function dhlApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -23,7 +23,7 @@ export async function dhlApiRequest( ): Promise { const credentials = (await this.getCredentials('dhlApi')) as { apiKey: string }; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'DHL-API-Key': credentials.apiKey, }, @@ -55,7 +55,7 @@ export async function validateCredentials( apiKey: string; }; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'DHL-API-Key': apiKey, }, diff --git a/packages/nodes-base/nodes/Discord/test/v2/node/channel/get.test.ts b/packages/nodes-base/nodes/Discord/test/v2/node/channel/get.test.ts index 45f98089c7..002e570603 100644 --- a/packages/nodes-base/nodes/Discord/test/v2/node/channel/get.test.ts +++ b/packages/nodes-base/nodes/Discord/test/v2/node/channel/get.test.ts @@ -1,6 +1,5 @@ -import type { INodeTypes } from 'n8n-workflow'; +import type { INodeTypes, IRequestOptions } from 'n8n-workflow'; import nock from 'nock'; -import type { OptionsWithUrl } from 'request-promise-native'; import * as transport from '../../../../v2/transport/helpers'; import { getResultNodeData, setup, workflowToTests } from '@test/nodes/Helpers'; import type { WorkflowTestData } from '@test/nodes/types'; @@ -9,7 +8,7 @@ import { executeWorkflow } from '@test/nodes/ExecuteWorkflow'; const requestApiSpy = jest.spyOn(transport, 'requestApi'); requestApiSpy.mockImplementation( - async (options: OptionsWithUrl, credentialType: string, endpoint: string) => { + async (options: IRequestOptions, credentialType: string, endpoint: string) => { if (endpoint === '/users/@me/guilds') { return { headers: {}, diff --git a/packages/nodes-base/nodes/Discord/v1/DiscordV1.node.ts b/packages/nodes-base/nodes/Discord/v1/DiscordV1.node.ts index bf04088fd5..54dd921797 100644 --- a/packages/nodes-base/nodes/Discord/v1/DiscordV1.node.ts +++ b/packages/nodes-base/nodes/Discord/v1/DiscordV1.node.ts @@ -6,6 +6,7 @@ import type { INodeType, INodeTypeBaseDescription, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; import { jsonParse, NodeApiError, NodeOperationError, sleep } from 'n8n-workflow'; @@ -216,7 +217,7 @@ export class DiscordV1 implements INodeType { if (!body.payload_json) delete body.payload_json; if (!body.attachments) delete body.attachments; - let requestOptions; + let requestOptions: IRequestOptions; if (!body.payload_json) { requestOptions = { diff --git a/packages/nodes-base/nodes/Discord/v2/transport/discord.api.ts b/packages/nodes-base/nodes/Discord/v2/transport/discord.api.ts index 5c3c3db1ba..153e37650b 100644 --- a/packages/nodes-base/nodes/Discord/v2/transport/discord.api.ts +++ b/packages/nodes-base/nodes/Discord/v2/transport/discord.api.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUrl } from 'request'; - import type { IDataObject, IExecuteFunctions, IExecuteSingleFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, } from 'n8n-workflow'; import { sleep, NodeApiError, jsonParse } from 'n8n-workflow'; @@ -15,7 +15,7 @@ import { getCredentialsType, requestApi } from './helpers'; export async function discordApiRequest( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body?: IDataObject, qs?: IDataObject, @@ -25,7 +25,7 @@ export async function discordApiRequest( const credentialType = getCredentialsType(authentication); - const options: OptionsWithUrl = { + const options: IRequestOptions = { headers, method, qs, @@ -59,7 +59,7 @@ export async function discordApiRequest( export async function discordApiMultiPartRequest( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, formData: FormData, ) { @@ -70,7 +70,7 @@ export async function discordApiMultiPartRequest( const credentialType = getCredentialsType(authentication); - const options: OptionsWithUrl = { + const options: IRequestOptions = { headers, method, formData, diff --git a/packages/nodes-base/nodes/Discord/v2/transport/helpers.ts b/packages/nodes-base/nodes/Discord/v2/transport/helpers.ts index 39341c5f4f..3abb791a99 100644 --- a/packages/nodes-base/nodes/Discord/v2/transport/helpers.ts +++ b/packages/nodes-base/nodes/Discord/v2/transport/helpers.ts @@ -1,11 +1,10 @@ -import type { OptionsWithUrl } from 'request'; - import type { IDataObject, IExecuteFunctions, IExecuteSingleFunctions, IHookFunctions, ILoadOptionsFunctions, + IRequestOptions, } from 'n8n-workflow'; export const getCredentialsType = (authentication: string) => { @@ -28,7 +27,7 @@ export const getCredentialsType = (authentication: string) => { export async function requestApi( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, - options: OptionsWithUrl, + options: IRequestOptions, credentialType: string, endpoint: string, ) { diff --git a/packages/nodes-base/nodes/Discourse/GenericFunctions.ts b/packages/nodes-base/nodes/Discourse/GenericFunctions.ts index cf3b09a202..8a66a6296d 100644 --- a/packages/nodes-base/nodes/Discourse/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Discourse/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function discourseApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -19,7 +19,7 @@ export async function discourseApiRequest( ): Promise { const credentials = (await this.getCredentials('discourseApi')) as { url: string }; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, @@ -39,7 +39,7 @@ export async function discourseApiRequest( export async function discourseApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Disqus/Disqus.node.ts b/packages/nodes-base/nodes/Disqus/Disqus.node.ts index e348702a51..a494eb9392 100644 --- a/packages/nodes-base/nodes/Disqus/Disqus.node.ts +++ b/packages/nodes-base/nodes/Disqus/Disqus.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -576,7 +577,7 @@ export class Disqus implements INodeType { const operation = this.getNodeParameter('operation', 0); let endpoint = ''; - let requestMethod = ''; + let requestMethod: IHttpRequestMethods; let qs: IDataObject; for (let i = 0; i < items.length; i++) { diff --git a/packages/nodes-base/nodes/Disqus/GenericFunctions.ts b/packages/nodes-base/nodes/Disqus/GenericFunctions.ts index 0b96d755d6..8d03fe0407 100644 --- a/packages/nodes-base/nodes/Disqus/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Disqus/GenericFunctions.ts @@ -1,16 +1,17 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function disqusApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, qs: IDataObject = {}, uri?: string, body: IDataObject = {}, @@ -31,7 +32,7 @@ export async function disqusApiRequest( } } - let options: OptionsWithUri = { + let options: IRequestOptions = { method, body, uri: `https://disqus.com/api/3.0/${uri}?${queryStringElements.join('&')}`, @@ -55,7 +56,7 @@ export async function disqusApiRequest( */ export async function disqusApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, qs: IDataObject = {}, uri?: string, body: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Drift/GenericFunctions.ts b/packages/nodes-base/nodes/Drift/GenericFunctions.ts index aa73872818..44bfb8c2a7 100644 --- a/packages/nodes-base/nodes/Drift/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Drift/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, @@ -7,12 +5,14 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function driftApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function driftApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: {}, method, body, diff --git a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts index 2b2e006a60..9dd9c1f0cd 100644 --- a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts +++ b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts @@ -1,6 +1,7 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, INodeExecutionData, INodeType, INodeTypeDescription, @@ -697,7 +698,7 @@ export class Dropbox implements INodeType { const operation = this.getNodeParameter('operation', 0); let endpoint = ''; - let requestMethod = ''; + let requestMethod: IHttpRequestMethods = 'GET'; let returnAll = false; let property = ''; let body: IDataObject | Buffer; diff --git a/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts b/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts index fedf8a8134..86e9d65569 100644 --- a/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts @@ -1,6 +1,11 @@ -import type { OptionsWithUri } from 'request'; - -import type { IDataObject, IExecuteFunctions, IHookFunctions, JsonObject } from 'n8n-workflow'; +import type { + IDataObject, + IExecuteFunctions, + IHookFunctions, + IHttpRequestMethods, + IRequestOptions, + JsonObject, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -9,14 +14,14 @@ import { NodeApiError } from 'n8n-workflow'; */ export async function dropboxApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, query: IDataObject = {}, - headers: object = {}, + headers: IDataObject = {}, option: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers, method, qs: query, @@ -47,7 +52,7 @@ export async function dropboxApiRequest( export async function dropboxpiRequestAllItems( this: IExecuteFunctions | IHookFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts b/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts index a8f8dd89ce..98b5516520 100644 --- a/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts +++ b/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts @@ -4,21 +4,21 @@ import type { IDataObject, ILoadOptionsFunctions, IPairedItemData, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Make an authenticated API request to Bubble. */ export async function dropcontactApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, qs: IDataObject, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, uri: `https://api.dropcontact.io${endpoint}`, qs, diff --git a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts index 8f6f5aeda0..427ac764b2 100644 --- a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, IHookFunctions, IWebhookFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -17,7 +17,7 @@ const getBaseUrl = ({ environment, domain, subdomain }: ERPNextApiCredentials) = export async function erpNextApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, query: IDataObject = {}, @@ -27,7 +27,7 @@ export async function erpNextApiRequest( const credentials = (await this.getCredentials('erpNextApi')) as ERPNextApiCredentials; const baseUrl = getBaseUrl(credentials); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -68,7 +68,7 @@ export async function erpNextApiRequest( export async function erpNextApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Egoi/GenericFunctions.ts b/packages/nodes-base/nodes/Egoi/GenericFunctions.ts index 6a42d95f4b..a20e5e8761 100644 --- a/packages/nodes-base/nodes/Egoi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Egoi/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUrl } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -21,7 +21,7 @@ const fieldCache: { export async function egoiApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -30,7 +30,7 @@ export async function egoiApiRequest( ): Promise { const credentials = await this.getCredentials('egoiApi'); - const options: OptionsWithUrl = { + const options: IRequestOptions = { headers: { accept: 'application/json', Apikey: `${credentials.apiKey}`, @@ -64,7 +64,7 @@ export async function getFields(this: IExecuteFunctions, listId: string) { export async function egoiApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts index 72ff4d3602..7602033765 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts @@ -9,10 +9,10 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import { elasticSecurityApiRequest, getConnector, @@ -132,7 +132,7 @@ export class ElasticSecurity implements INodeType { const endpoint = '/cases/status'; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Basic ${token}`, 'kbn-xsrf': true, diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts index 5b588cf167..696170cff1 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts @@ -3,11 +3,11 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import type { Connector, ElasticSecurityApiCredentials } from './types'; export function tolerateTrailingSlash(baseUrl: string) { @@ -16,7 +16,7 @@ export function tolerateTrailingSlash(baseUrl: string) { export async function elasticSecurityApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -31,7 +31,7 @@ export async function elasticSecurityApiRequest( const token = Buffer.from(`${username}:${password}`).toString('base64'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Basic ${token}`, 'kbn-xsrf': true, @@ -64,7 +64,7 @@ export async function elasticSecurityApiRequest( export async function elasticSecurityApiRequestAllItems( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -89,7 +89,7 @@ export async function elasticSecurityApiRequestAllItems( export async function handleListing( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts b/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts index 56d137a03a..ed013079f8 100644 --- a/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts @@ -1,13 +1,17 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IDataObject, + JsonObject, + IRequestOptions, + IHttpRequestMethods, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { ElasticsearchApiCredentials } from './types'; export async function elasticsearchApiRequest( this: IExecuteFunctions, - method: 'GET' | 'PUT' | 'POST' | 'DELETE', + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -16,7 +20,7 @@ export async function elasticsearchApiRequest( 'elasticsearchApi', )) as ElasticsearchApiCredentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, diff --git a/packages/nodes-base/nodes/Emelia/GenericFunctions.ts b/packages/nodes-base/nodes/Emelia/GenericFunctions.ts index ae52f1719b..6ac76d3561 100644 --- a/packages/nodes-base/nodes/Emelia/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Emelia/GenericFunctions.ts @@ -7,6 +7,9 @@ import type { INodeCredentialTestResult, INodePropertyOptions, JsonObject, + IRequestOptions, + IHttpRequestMethods, + IDataObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -15,14 +18,14 @@ import { NodeApiError } from 'n8n-workflow'; */ export async function emeliaApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object = {}, - qs: object = {}, + qs: IDataObject = {}, ) { const { apiKey } = (await this.getCredentials('emeliaApi')) as { apiKey: string }; - const options = { + const options: IRequestOptions = { headers: { Authorization: apiKey, }, diff --git a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts index 8ea91020aa..b2201900d5 100644 --- a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -12,7 +12,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function eventbriteApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function eventbriteApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: {}, method, qs, @@ -56,7 +56,7 @@ export async function eventbriteApiRequest( export async function eventbriteApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/ExecuteWorkflow/GenericFunctions.ts b/packages/nodes-base/nodes/ExecuteWorkflow/GenericFunctions.ts index 077e4f5001..9e212eb194 100644 --- a/packages/nodes-base/nodes/ExecuteWorkflow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ExecuteWorkflow/GenericFunctions.ts @@ -1,6 +1,6 @@ import { readFile as fsReadFile } from 'fs/promises'; import { NodeOperationError, jsonParse } from 'n8n-workflow'; -import type { IExecuteFunctions, IExecuteWorkflowInfo } from 'n8n-workflow'; +import type { IExecuteFunctions, IExecuteWorkflowInfo, IRequestOptions } from 'n8n-workflow'; export async function getWorkflowInfo(this: IExecuteFunctions, source: string, itemIndex = 0) { const workflowInfo: IExecuteWorkflowInfo = {}; @@ -43,7 +43,7 @@ export async function getWorkflowInfo(this: IExecuteFunctions, source: string, i uri: workflowUrl, json: true, gzip: true, - }; + } satisfies IRequestOptions; const response = await this.helpers.request(requestOptions); workflowInfo.code = response; diff --git a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts index b457a2c621..78b80e6f64 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts @@ -1,15 +1,15 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, INodeExecutionData, INodeType, INodeTypeDescription, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - export class FacebookGraphApi implements INodeType { description: INodeTypeDescription = { displayName: 'Facebook Graph API', @@ -308,7 +308,10 @@ export class FacebookGraphApi implements INodeType { const graphApiCredentials = await this.getCredentials('facebookGraphApi'); const hostUrl = this.getNodeParameter('hostUrl', itemIndex) as string; - const httpRequestMethod = this.getNodeParameter('httpRequestMethod', itemIndex) as string; + const httpRequestMethod = this.getNodeParameter( + 'httpRequestMethod', + itemIndex, + ) as IHttpRequestMethods; let graphApiVersion = this.getNodeParameter('graphApiVersion', itemIndex) as string; const node = this.getNodeParameter('node', itemIndex) as string; const edge = this.getNodeParameter('edge', itemIndex) as string; @@ -323,7 +326,10 @@ export class FacebookGraphApi implements INodeType { uri = `${uri}/${edge}`; } - const requestOptions: OptionsWithUri = { + const qs: IDataObject = { + access_token: graphApiCredentials.accessToken, + }; + const requestOptions: IRequestOptions = { headers: { accept: 'application/json,text/*;q=0.99', }, @@ -331,9 +337,6 @@ export class FacebookGraphApi implements INodeType { uri, json: true, gzip: true, - qs: { - access_token: graphApiCredentials.accessToken, - }, rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false), }; @@ -343,7 +346,7 @@ export class FacebookGraphApi implements INodeType { const fields = options.fields as IDataObject; if (fields.field !== undefined) { const fieldsCsv = (fields.field as IDataObject[]).map((field) => field.name).join(','); - requestOptions.qs.fields = fieldsCsv; + qs.fields = fieldsCsv; } } @@ -353,11 +356,13 @@ export class FacebookGraphApi implements INodeType { if (queryParameters.parameter !== undefined) { for (const queryParameter of queryParameters.parameter as IDataObject[]) { - requestOptions.qs[queryParameter.name as string] = queryParameter.value; + qs[queryParameter.name as string] = queryParameter.value; } } } + requestOptions.qs = qs; + // Add the query parameters defined as a JSON object if (options.queryParametersJson) { let queryParametersJsonObj = {}; @@ -366,7 +371,6 @@ export class FacebookGraphApi implements INodeType { } catch { /* Do nothing, at least for now */ } - const qs = requestOptions.qs; requestOptions.qs = { ...qs, ...queryParametersJsonObj, diff --git a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts index 703ec0c7ce..94d36bd183 100644 --- a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -14,7 +14,7 @@ import { capitalCase } from 'change-case'; export async function facebookApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -32,7 +32,7 @@ export async function facebookApiRequest( qs.access_token = credentials.accessToken; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { accept: 'application/json,text/*;q=0.99', }, diff --git a/packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts b/packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts index 759547f601..a608605096 100644 --- a/packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -20,12 +20,12 @@ import type { export async function facebookApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body = {}, qs: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { accept: 'application/json', }, @@ -51,7 +51,7 @@ export async function appAccessTokenRead( ): Promise<{ access_token: string }> { const credentials = await this.getCredentials('facebookLeadAdsOAuth2Api'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'content-type': 'application/x-www-form-urlencoded', }, @@ -73,7 +73,7 @@ export async function appAccessTokenRead( export async function facebookAppApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body?: { type: 'json'; payload: IDataObject } | { type: 'form'; payload: IDataObject }, qs: IDataObject = {}, @@ -81,7 +81,7 @@ export async function facebookAppApiRequest( const tokenResponse = await appAccessTokenRead.call(this); const appAccessToken = tokenResponse.access_token; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { accept: 'application/json', authorization: `Bearer ${appAccessToken}`, @@ -164,7 +164,7 @@ export async function facebookEntityDetail( export async function facebookPageApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body = {}, qs: IDataObject = {}, @@ -172,7 +172,7 @@ export async function facebookPageApiRequest( const pageId = this.getNodeParameter('page', '', { extractValue: true }) as string; const page = (await facebookEntityDetail.call(this, pageId)) as FacebookPage; const pageAccessToken = page.access_token; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { accept: 'application/json', authorization: `Bearer ${pageAccessToken}`, diff --git a/packages/nodes-base/nodes/Figma/GenericFunctions.ts b/packages/nodes-base/nodes/Figma/GenericFunctions.ts index a2f8324b0f..cbd5618558 100644 --- a/packages/nodes-base/nodes/Figma/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Figma/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function figmaApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function figmaApiRequest( ): Promise { const credentials = await this.getCredentials('figmaApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'X-FIGMA-TOKEN': credentials.accessToken }, method, body, diff --git a/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts b/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts index 45639a38c2..29352a9425 100644 --- a/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts +++ b/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts @@ -7,10 +7,10 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import { getFields, getPortals, @@ -683,7 +683,7 @@ export class FileMaker implements INodeType { throw new NodeOperationError(this.getNode(), error as string); } - let requestOptions: OptionsWithUri; + let requestOptions: IRequestOptions; const host = credentials.host as string; const database = credentials.db as string; diff --git a/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts b/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts index 52e0faac60..3c3100fa62 100644 --- a/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts @@ -4,11 +4,10 @@ import type { IDataObject, INodePropertyOptions, JsonObject, + IRequestOptions, } from 'n8n-workflow'; import { ApplicationError, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - interface ScriptsOptions { script?: any; 'script.param'?: any; @@ -40,7 +39,7 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions): const url = `https://${host}/fmi/data/v1/databases/${db}/sessions`; // Reset all values - const requestOptions: OptionsWithUri = { + const requestOptions: IRequestOptions = { uri: url, headers: {}, method: 'POST', @@ -114,7 +113,7 @@ export async function layoutsApiRequest( const db = credentials.db as string; const url = `https://${host}/fmi/data/v1/databases/${db}/layouts`; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${token}`, }, @@ -146,7 +145,7 @@ export async function getFields(this: ILoadOptionsFunctions): Promise { const db = credentials.db as string; const url = `https://${host}/fmi/data/v1/databases/${db}/layouts/${layout}`; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${token}`, }, @@ -177,7 +176,7 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise { const db = credentials.db as string; const url = `https://${host}/fmi/data/v1/databases/${db}/layouts/${layout}`; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${token}`, }, @@ -222,7 +221,7 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise { const db = credentials.db as string; const url = `https://${host}/fmi/data/v1/databases/${db}/scripts`; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${token}`, }, @@ -254,7 +253,7 @@ export async function logout( const url = `https://${host}/fmi/data/v1/databases/${db}/sessions/${token}`; // Reset all values - const requestOptions: OptionsWithUri = { + const requestOptions: IRequestOptions = { uri: url, headers: {}, method: 'DELETE', diff --git a/packages/nodes-base/nodes/Flow/GenericFunctions.ts b/packages/nodes-base/nodes/Flow/GenericFunctions.ts index e2b110df4c..0f304e6415 100644 --- a/packages/nodes-base/nodes/Flow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Flow/GenericFunctions.ts @@ -1,16 +1,17 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function flowApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +21,7 @@ export async function flowApiRequest( ): Promise { const credentials = await this.getCredentials('flowApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.accessToken}` }, method, qs, @@ -47,7 +48,7 @@ export async function flowApiRequest( export async function FlowApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts index e4ff44f3e2..52dfbf944e 100644 --- a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts @@ -4,6 +4,8 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { ApplicationError, NodeApiError } from 'n8n-workflow'; @@ -36,7 +38,7 @@ async function getToken( uri: `${base}/user/login`, json: true, resolveWithFullResponse: true, - }; + } satisfies IRequestOptions; try { const responseObject = await this.helpers.request(options); @@ -54,7 +56,7 @@ async function getToken( */ export async function formIoApiRequest( this: IHookFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body = {}, qs = {}, diff --git a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts index d4dbadf30c..fe53058349 100644 --- a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts @@ -6,11 +6,11 @@ import type { IWebhookFunctions, INodePropertyOptions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { ApplicationError, NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - export interface IFormstackFieldDefinitionType { id: string; label: string; @@ -51,14 +51,14 @@ export const enum FormstackFieldFormat { */ export async function apiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, body, @@ -93,7 +93,7 @@ export async function apiRequest( */ export async function apiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, dataKey: string, diff --git a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts index 2966306677..59578dfea3 100644 --- a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { BINARY_ENCODING, NodeApiError } from 'n8n-workflow'; export async function freshdeskApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -24,7 +24,7 @@ export async function freshdeskApiRequest( const endpoint = 'freshdesk.com/api/v2'; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', Authorization: `${Buffer.from(apiKey).toString(BINARY_ENCODING)}`, @@ -51,7 +51,7 @@ export async function freshdeskApiRequest( export async function freshdeskApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts index f1894288b9..558a34c125 100644 --- a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts @@ -4,11 +4,11 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import { omit } from 'lodash'; import type { AddressFixedCollection, @@ -19,7 +19,7 @@ import type { export async function freshserviceApiRequest( this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -29,7 +29,7 @@ export async function freshserviceApiRequest( )) as FreshserviceCredentials; const encodedApiKey = Buffer.from(`${apiKey}:X`).toString('base64'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Basic ${encodedApiKey}`, }, @@ -75,7 +75,7 @@ export async function freshserviceApiRequest( export async function freshserviceApiRequestAllItems( this: IExecuteFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -98,7 +98,7 @@ export async function freshserviceApiRequestAllItems( export async function handleListing( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, diff --git a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts index 8d4f33bb52..5bcdafc5ae 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts @@ -3,11 +3,11 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import omit from 'lodash/omit'; import type { FreshworksConfigResponse, @@ -18,14 +18,14 @@ import type { export async function freshworksCrmApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, ) { const { domain } = (await this.getCredentials('freshworksCrmApi')) as FreshworksCrmApiCredentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, @@ -80,7 +80,7 @@ export async function getAllItemsViewId( export async function freshworksCrmApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -102,7 +102,7 @@ export async function freshworksCrmApiRequestAllItems( export async function handleListing( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, diff --git a/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts b/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts index cfe9090424..1271dea98c 100644 --- a/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts +++ b/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -12,7 +12,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function getresponseApiRequest( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -22,7 +22,7 @@ export async function getresponseApiRequest( ): Promise { const authentication = this.getNodeParameter('authentication', 0, 'apiKey') as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -51,7 +51,7 @@ export async function getresponseApiRequest( export async function getResponseApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts index d8ff358b75..ad53a7673c 100644 --- a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts @@ -1,15 +1,15 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, } from 'n8n-workflow'; export async function ghostApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -32,7 +32,7 @@ export async function ghostApiRequest( const credentials = await this.getCredentials(credentialType); - const options: OptionsWithUri = { + const options: IRequestOptions = { method, qs: query, uri: uri || `${credentials.url}/ghost/api/${version}${endpoint}`, @@ -46,7 +46,7 @@ export async function ghostApiRequest( export async function ghostApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Github/GenericFunctions.ts b/packages/nodes-base/nodes/Github/GenericFunctions.ts index 12672ab212..a27618b3db 100644 --- a/packages/nodes-base/nodes/Github/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Github/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, IHookFunctions, IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -15,13 +15,13 @@ import { NodeApiError, NodeOperationError } from 'n8n-workflow'; */ export async function githubApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, - query?: object, + query?: IDataObject, option: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: { 'User-Agent': 'n8n', @@ -92,7 +92,7 @@ export async function getFileSha( export async function githubApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Github/Github.node.ts b/packages/nodes-base/nodes/Github/Github.node.ts index 6b3f2e4a7f..662996ab21 100644 --- a/packages/nodes-base/nodes/Github/Github.node.ts +++ b/packages/nodes-base/nodes/Github/Github.node.ts @@ -1,6 +1,7 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, INodeExecutionData, INodeType, INodeTypeDescription, @@ -1746,7 +1747,7 @@ export class Github implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; const operation = this.getNodeParameter('operation', 0); diff --git a/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts b/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts index 21c9da8f8d..c898041b54 100644 --- a/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts @@ -1,6 +1,12 @@ -import type { IExecuteFunctions, IHookFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IHookFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; /** * Make an API request to Gitlab @@ -8,13 +14,13 @@ import type { OptionsWithUri } from 'request'; */ export async function gitlabApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, - query?: object, + query?: IDataObject, option: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: {}, body, @@ -51,7 +57,7 @@ export async function gitlabApiRequest( export async function gitlabApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts b/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts index ecfece1211..78d1004414 100644 --- a/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts +++ b/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts @@ -1,6 +1,7 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, INodeExecutionData, INodeType, INodeTypeDescription, @@ -1373,7 +1374,7 @@ export class Gitlab implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; let returnAll = false; diff --git a/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts b/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts index f86af87550..414a0e1cbb 100644 --- a/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts @@ -2,14 +2,14 @@ import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodePropertyOptions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import moment from 'moment-timezone'; import * as losslessJSON from 'lossless-json'; @@ -27,7 +27,7 @@ function convertLosslessNumber(key: any, value: any) { */ export async function goToWebinarApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, body: IDataObject | IDataObject[], @@ -36,7 +36,7 @@ export async function goToWebinarApiRequest( const operation = this.getNodeParameter('operation', 0); const resource = this.getNodeParameter('resource', 0); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'user-agent': 'n8n', Accept: 'application/json', @@ -86,7 +86,7 @@ export async function goToWebinarApiRequest( */ export async function goToWebinarApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, query: IDataObject, body: IDataObject, diff --git a/packages/nodes-base/nodes/Google/Analytics/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Analytics/v1/GenericFunctions.ts index 79ba392e2a..fb05127647 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v1/GenericFunctions.ts @@ -1,15 +1,16 @@ -import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -18,7 +19,7 @@ export async function googleApiRequest( ) { const baseURL = 'https://analyticsreporting.googleapis.com'; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -60,7 +61,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Google/Analytics/v1/GoogleAnalyticsV1.node.ts b/packages/nodes-base/nodes/Google/Analytics/v1/GoogleAnalyticsV1.node.ts index 2d264622ac..9f38d2a55a 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v1/GoogleAnalyticsV1.node.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v1/GoogleAnalyticsV1.node.ts @@ -8,6 +8,7 @@ import type { INodeType, INodeTypeBaseDescription, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -153,7 +154,7 @@ export class GoogleAnalyticsV1 implements INodeType { const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); - let method = ''; + let method: IHttpRequestMethods = 'GET'; const qs: IDataObject = {}; let endpoint = ''; let responseData; diff --git a/packages/nodes-base/nodes/Google/Analytics/v2/transport/index.ts b/packages/nodes-base/nodes/Google/Analytics/v2/transport/index.ts index cc955f7409..01e0f34f77 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v2/transport/index.ts @@ -1,15 +1,16 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -22,7 +23,7 @@ export async function googleApiRequest( ? 'https://analyticsdata.googleapis.com' : 'https://analyticsreporting.googleapis.com'; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -66,7 +67,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/executeQuery.test.ts b/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/executeQuery.test.ts index d7aa4ad566..95a52e559d 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/executeQuery.test.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/executeQuery.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../v2/transport', () => { const originalModule = jest.requireActual('../../../v2/transport'); return { ...originalModule, - googleApiRequest: jest.fn(async (method: string, resource: string) => { + googleApiRequest: jest.fn(async (method: IHttpRequestMethods, resource: string) => { if (resource === '/v2/projects/test-project/jobs' && method === 'POST') { return { jobReference: { diff --git a/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/insert.autoMapMode.test.ts b/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/insert.autoMapMode.test.ts index b1ca9f279b..7caccca38f 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/insert.autoMapMode.test.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/insert.autoMapMode.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../v2/transport', () => { const originalModule = jest.requireActual('../../../v2/transport'); return { ...originalModule, - googleApiRequest: jest.fn(async (method: string, resource: string) => { + googleApiRequest: jest.fn(async (method: IHttpRequestMethods, resource: string) => { if ( resource === '/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/num_text' && diff --git a/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/insert.manualMode.test.ts b/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/insert.manualMode.test.ts index 6d3dea8d92..6af6c8e51c 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/insert.manualMode.test.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/test/v2/node/insert.manualMode.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../v2/transport', () => { const originalModule = jest.requireActual('../../../v2/transport'); return { ...originalModule, - googleApiRequest: jest.fn(async (method: string, resource: string) => { + googleApiRequest: jest.fn(async (method: IHttpRequestMethods, resource: string) => { if ( resource === '/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/test_json' && diff --git a/packages/nodes-base/nodes/Google/BigQuery/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Google/BigQuery/v1/GenericFunctions.ts index 9a955f698c..d4456f318b 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/v1/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import { getGoogleAccessToken } from '../../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, @@ -24,7 +24,7 @@ export async function googleApiRequest( 'serviceAccount', ) as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -68,7 +68,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/BigQuery/v2/transport/index.ts b/packages/nodes-base/nodes/Google/BigQuery/v2/transport/index.ts index b4c39c90bb..d2ed271e24 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/v2/transport/index.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -11,7 +11,7 @@ import { getGoogleAccessToken } from '../../../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -24,7 +24,7 @@ export async function googleApiRequest( 'serviceAccount', ) as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -70,7 +70,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts index 65e44048e4..ab8d73f58e 100644 --- a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { getGoogleAccessToken } from '../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, @@ -23,7 +23,7 @@ export async function googleApiRequest( 0, 'serviceAccount', ) as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -67,7 +67,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts index 69f3e6671b..63b9ba1012 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts @@ -1,12 +1,12 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeListSearchItems, INodeListSearchResult, IPollFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -16,14 +16,14 @@ import { RRule } from 'rrule'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -50,7 +50,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts index 6041dca5ef..442ba4799d 100644 --- a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeProperties, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -13,7 +13,7 @@ import { getGoogleAccessToken } from '../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -22,7 +22,7 @@ export async function googleApiRequest( noCredentials = false, encoding?: null | undefined, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -69,7 +69,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts b/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts index 2547e7fd56..60b7781d2d 100644 --- a/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts +++ b/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts @@ -9,10 +9,10 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import moment from 'moment-timezone'; import jwt from 'jsonwebtoken'; import type { IMessage, IMessageUi } from './MessageInterface'; @@ -154,7 +154,7 @@ export class GoogleChat implements INodeType { }, ); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, diff --git a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts index c299a40782..58cb39c8b0 100644 --- a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -18,7 +18,7 @@ export async function googleApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', diff --git a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts index 50b116a69f..6c07a1a0da 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -18,7 +18,7 @@ export async function googleApiRequest( uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -46,7 +46,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts index 01f707891b..02183796d3 100644 --- a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -12,7 +12,7 @@ import { getGoogleAccessToken } from '../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs?: IDataObject, @@ -24,7 +24,7 @@ export async function googleApiRequest( 'serviceAccount', ) as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -57,7 +57,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs?: IDataObject, diff --git a/packages/nodes-base/nodes/Google/Drive/test/v2/node/drive/list.test.ts b/packages/nodes-base/nodes/Google/Drive/test/v2/node/drive/list.test.ts index 8693a00352..3d5507386d 100644 --- a/packages/nodes-base/nodes/Google/Drive/test/v2/node/drive/list.test.ts +++ b/packages/nodes-base/nodes/Google/Drive/test/v2/node/drive/list.test.ts @@ -10,12 +10,12 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - googleApiRequest: jest.fn(async function (method: string) { + googleApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'GET') { return {}; } }), - googleApiRequestAllItems: jest.fn(async function (method: string) { + googleApiRequestAllItems: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'GET') { return {}; } diff --git a/packages/nodes-base/nodes/Google/Drive/test/v2/node/file/move.test.ts b/packages/nodes-base/nodes/Google/Drive/test/v2/node/file/move.test.ts index a3665a4df7..ead8e50d66 100644 --- a/packages/nodes-base/nodes/Google/Drive/test/v2/node/file/move.test.ts +++ b/packages/nodes-base/nodes/Google/Drive/test/v2/node/file/move.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - googleApiRequest: jest.fn(async function (method: string) { + googleApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'GET') { return { parents: ['parentFolderIDxxxxxx'], diff --git a/packages/nodes-base/nodes/Google/Drive/test/v2/node/file/upload.test.ts b/packages/nodes-base/nodes/Google/Drive/test/v2/node/file/upload.test.ts index 54c93caa66..abc98839f9 100644 --- a/packages/nodes-base/nodes/Google/Drive/test/v2/node/file/upload.test.ts +++ b/packages/nodes-base/nodes/Google/Drive/test/v2/node/file/upload.test.ts @@ -11,7 +11,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - googleApiRequest: jest.fn(async function (method: string) { + googleApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'POST') { return { headers: { location: 'someLocation' }, diff --git a/packages/nodes-base/nodes/Google/Drive/test/v2/node/fileFolder/search.test.ts b/packages/nodes-base/nodes/Google/Drive/test/v2/node/fileFolder/search.test.ts index 3f10deeac3..df26385aa4 100644 --- a/packages/nodes-base/nodes/Google/Drive/test/v2/node/fileFolder/search.test.ts +++ b/packages/nodes-base/nodes/Google/Drive/test/v2/node/fileFolder/search.test.ts @@ -10,12 +10,12 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - googleApiRequest: jest.fn(async function (method: string) { + googleApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'GET') { return {}; } }), - googleApiRequestAllItems: jest.fn(async function (method: string) { + googleApiRequestAllItems: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'GET') { return {}; } diff --git a/packages/nodes-base/nodes/Google/Drive/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Drive/v1/GenericFunctions.ts index b8ecafdf31..16171fb75f 100644 --- a/packages/nodes-base/nodes/Google/Drive/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Drive/v1/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, IPollFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -13,7 +13,7 @@ import { getGoogleAccessToken } from '../../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, @@ -26,7 +26,7 @@ export async function googleApiRequest( 'serviceAccount', ) as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -66,7 +66,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts index 2191c5bd93..328fa246fe 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -12,14 +12,14 @@ import moment from 'moment-timezone'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, uri: string | null = null, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -51,7 +51,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts index 71b03a3369..fb19c1d4d8 100644 --- a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUrl } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -11,7 +11,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, projectId: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -23,7 +23,7 @@ export async function googleApiRequest( 'googleFirebaseRealtimeDatabaseOAuth2Api', )) as IDataObject; - const options: OptionsWithUrl = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -55,7 +55,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, projectId: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts index 40594b0926..9f66450966 100644 --- a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts +++ b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts @@ -7,6 +7,7 @@ import type { INodeType, INodeTypeDescription, JsonObject, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -180,7 +181,7 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { try { const projectId = this.getNodeParameter('projectId', i) as string; - let method = 'GET', + let method: IHttpRequestMethods = 'GET', attributes = ''; const document: IDataObject = {}; if (operation === 'create') { diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts index 4c9d15b0d6..7f30fe6812 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -18,7 +18,7 @@ export async function googleApiRequest( uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -45,7 +45,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/GenericFunctions.ts b/packages/nodes-base/nodes/Google/GenericFunctions.ts index 8658366df5..51ab4a0fb9 100644 --- a/packages/nodes-base/nodes/Google/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/GenericFunctions.ts @@ -4,9 +4,9 @@ import type { ICredentialTestFunctions, IDataObject, IPollFunctions, + IRequestOptions, } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import moment from 'moment-timezone'; import * as jwt from 'jsonwebtoken'; @@ -90,7 +90,7 @@ export async function getGoogleAccessToken( }, ); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, diff --git a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts index 2d84624fa0..8e0bfa58d4 100644 --- a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts @@ -1,15 +1,15 @@ -import type { OptionsWithUri } from 'request'; - import { simpleParser } from 'mailparser'; import type { IBinaryKeyData, IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INode, INodeExecutionData, IPollFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -43,14 +43,14 @@ import { getGoogleAccessToken } from '../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}, ) { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -265,7 +265,7 @@ export async function encodeEmail(email: IEmail) { export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, 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 dc5ad0b057..03d40ef2d0 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts @@ -3,6 +3,7 @@ import type { IBinaryKeyData, IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, @@ -179,7 +180,7 @@ export class GmailV1 implements INodeType { const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); - let method = ''; + let method: IHttpRequestMethods = 'GET'; let body: IDataObject = {}; let qs: IDataObject = {}; let endpoint = ''; diff --git a/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts index 9363d4392b..fdc1b043f5 100644 --- a/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts @@ -1,6 +1,4 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { IExecuteFunctions, IDataObject, JsonObject, IRequestOptions } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( @@ -9,7 +7,7 @@ export async function googleApiRequest( endpoint: string, body: IDataObject = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', diff --git a/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts index ac494e6f1a..c5c3feae78 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -18,7 +18,7 @@ export interface IGoogleAuthCredentials { export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -31,7 +31,7 @@ export async function googleApiRequest( 0, 'serviceAccount', ) as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -71,7 +71,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/transport/index.ts b/packages/nodes-base/nodes/Google/Sheet/v2/transport/index.ts index 40a0e09224..7a52b64faa 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/transport/index.ts @@ -1,9 +1,10 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, IPollFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -11,7 +12,7 @@ import { getGoogleAccessToken } from '../../../GenericFunctions'; export async function apiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -24,7 +25,7 @@ export async function apiRequest( 0, 'serviceAccount', ) as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -75,7 +76,7 @@ export async function apiRequest( export async function apiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts index ca669df2f7..98cbb28ecd 100644 --- a/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -12,7 +12,7 @@ import { getGoogleAccessToken } from '../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -22,7 +22,7 @@ export async function googleApiRequest( 0, 'serviceAccount', ) as string; - const options: OptionsWithUri & { headers: IDataObject } = { + const options: IRequestOptions & { headers: IDataObject } = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts index 41b67f833a..c0e69151e4 100644 --- a/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts @@ -1,23 +1,23 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -45,7 +45,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts index 1cfb4c66c3..d85912801a 100644 --- a/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -12,7 +12,7 @@ import { getGoogleAccessToken } from '../GenericFunctions'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -25,7 +25,7 @@ export async function googleApiRequest( 0, 'serviceAccount', ) as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -62,7 +62,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts b/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts index 3ef2240da1..acd718c1b2 100644 --- a/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -18,7 +18,7 @@ export async function googleApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -45,7 +45,7 @@ export async function googleApiRequest( export async function googleApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Gotify/GenericFunctions.ts b/packages/nodes-base/nodes/Gotify/GenericFunctions.ts index a963f106bb..8aa00f4ace 100644 --- a/packages/nodes-base/nodes/Gotify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gotify/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function gotifyApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -20,7 +20,7 @@ export async function gotifyApiRequest( ): Promise { const credentials = await this.getCredentials('gotifyApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: { 'X-Gotify-Key': method === 'POST' ? credentials.appApiToken : credentials.clientApiToken, @@ -47,7 +47,7 @@ export async function gotifyApiRequest( export async function gotifyApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Grafana/GenericFunctions.ts b/packages/nodes-base/nodes/Grafana/GenericFunctions.ts index 48d72bd9d7..9fb11f7c0e 100644 --- a/packages/nodes-base/nodes/Grafana/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Grafana/GenericFunctions.ts @@ -3,11 +3,11 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import type { GrafanaCredentials } from './types'; export function tolerateTrailingSlash(baseUrl: string) { @@ -16,7 +16,7 @@ export function tolerateTrailingSlash(baseUrl: string) { export async function grafanaApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -25,7 +25,7 @@ export async function grafanaApiRequest( const baseUrl = tolerateTrailingSlash(rawBaseUrl); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts b/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts index e125f79d82..2fdedf1a8b 100644 --- a/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts +++ b/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts @@ -7,12 +7,11 @@ import type { INodeTypeDescription, JsonObject, IRequestOptionsSimplified, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError, jsonParse } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; -import type { RequestPromiseOptions } from 'request-promise-native'; - export class GraphQL implements INodeType { description: INodeTypeDescription = { displayName: 'GraphQL', @@ -340,12 +339,16 @@ export class GraphQL implements INodeType { // Do nothing } - let requestOptions: OptionsWithUri & RequestPromiseOptions; + let requestOptions: IRequestOptions; const returnItems: INodeExecutionData[] = []; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { try { - const requestMethod = this.getNodeParameter('requestMethod', itemIndex, 'POST') as string; + const requestMethod = this.getNodeParameter( + 'requestMethod', + itemIndex, + 'POST', + ) as IHttpRequestMethods; const endpoint = this.getNodeParameter('endpoint', itemIndex, '') as string; const requestFormat = this.getNodeParameter( 'requestFormat', @@ -421,30 +424,29 @@ export class GraphQL implements INodeType { requestOptions.qs.query = gqlQuery; } else { if (requestFormat === 'json') { + const jsonBody = requestOptions.body as IDataObject; requestOptions.body = { - ...requestOptions.body, + ...jsonBody, query: gqlQuery, variables: this.getNodeParameter('variables', itemIndex, {}) as object, operationName: this.getNodeParameter('operationName', itemIndex) as string, }; - if (typeof requestOptions.body.variables === 'string') { + if (typeof jsonBody.variables === 'string') { try { - requestOptions.body.variables = JSON.parse( - (requestOptions.body.variables as string) || '{}', - ); + jsonBody.variables = JSON.parse(jsonBody.variables || '{}'); } catch (error) { throw new NodeOperationError( this.getNode(), 'Using variables failed:\n' + - (requestOptions.body.variables as string) + + (jsonBody.variables as string) + '\n\nWith error message:\n' + (error as string), { itemIndex }, ); } } - if (requestOptions.body.operationName === '') { - requestOptions.body.operationName = null; + if (jsonBody.operationName === '') { + jsonBody.operationName = null; } requestOptions.json = true; } else { diff --git a/packages/nodes-base/nodes/Grist/GenericFunctions.ts b/packages/nodes-base/nodes/Grist/GenericFunctions.ts index 1090be4837..e42d2e9aa7 100644 --- a/packages/nodes-base/nodes/Grist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Grist/GenericFunctions.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -17,7 +17,7 @@ import type { export async function gristApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject | number[] = {}, qs: IDataObject = {}, @@ -33,7 +33,7 @@ export async function gristApiRequest( ? `https://${customSubdomain}.getgrist.com/api${endpoint}` : `${selfHostedUrl}/api${endpoint}`; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${apiKey}`, }, diff --git a/packages/nodes-base/nodes/Grist/Grist.node.ts b/packages/nodes-base/nodes/Grist/Grist.node.ts index cf7c093149..d2db464994 100644 --- a/packages/nodes-base/nodes/Grist/Grist.node.ts +++ b/packages/nodes-base/nodes/Grist/Grist.node.ts @@ -8,10 +8,9 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import { gristApiRequest, parseAutoMappedInputs, @@ -86,7 +85,7 @@ export class Grist implements INodeType { ? `https://${customSubdomain}.getgrist.com/api${endpoint}` : `${selfHostedUrl}/api${endpoint}`; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${apiKey}`, }, diff --git a/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts b/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts index 1b19fccf05..8c4e810e67 100644 --- a/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts @@ -1,9 +1,10 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -11,7 +12,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function gumroadApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -22,7 +23,7 @@ export async function gumroadApiRequest( const credentials = await this.getCredentials('gumroadApi'); body = Object.assign({ access_token: credentials.accessToken }, body); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, qs, body, diff --git a/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts b/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts index b82ea5a647..414ce7a279 100644 --- a/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts @@ -4,22 +4,22 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Make an API request to HackerNews * */ export async function hackerNewsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, qs, uri: `http://hn.algolia.com/api/v1/${endpoint}`, @@ -41,7 +41,7 @@ export async function hackerNewsApiRequest( */ export async function hackerNewsApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, ): Promise { diff --git a/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts b/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts index f4a9c2072a..f6ac15258d 100644 --- a/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts @@ -4,14 +4,14 @@ import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, IPollFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - // Interfaces and Types ------------------------------------------------------------- interface IHaloPSATokens { scope: string; @@ -35,7 +35,7 @@ export async function getAccessTokens( ): Promise { const credentials = await this.getCredentials('haloPSAApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, @@ -60,7 +60,7 @@ export async function getAccessTokens( export async function haloPSAApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, resource: string, accessToken: string, body: IDataObject | IDataObject[] = {}, @@ -70,7 +70,7 @@ export async function haloPSAApiRequest( const resourceApiUrl = (await this.getCredentials('haloPSAApi')).resourceApiUrl as string; try { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${accessToken}`, 'User-Agent': 'https://n8n.io', @@ -96,7 +96,7 @@ export async function haloPSAApiRequest( return result; } catch (error) { const message = (error as JsonObject).message as string; - if (method === 'DELETE' || method === 'GET' || (method === 'UPDATE' && message)) { + if (method === 'DELETE' || method === 'GET' || (method === 'POST' && message)) { let newErrorMessage; if (message.includes('400')) { console.log(message); @@ -151,7 +151,7 @@ export async function haloPSAApiRequest( export async function haloPSAApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, accessToken: string, body = {}, @@ -224,7 +224,7 @@ export async function validateCredentials( ): Promise { const credentials = decryptedCredentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, diff --git a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts index 596d6e75bd..66c1865650 100644 --- a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts @@ -1,24 +1,24 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function harvestApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, qs: IDataObject, path: string, body: IDataObject = {}, option: IDataObject = {}, uri?: string, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Harvest-Account-Id': `${this.getNodeParameter('accountId', 0)}`, 'User-Agent': 'Harvest App', @@ -59,7 +59,7 @@ export async function harvestApiRequest( */ export async function harvestApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, qs: IDataObject, uri: string, resource: string, diff --git a/packages/nodes-base/nodes/Harvest/Harvest.node.ts b/packages/nodes-base/nodes/Harvest/Harvest.node.ts index 72b6cde3e6..79a6de23c6 100644 --- a/packages/nodes-base/nodes/Harvest/Harvest.node.ts +++ b/packages/nodes-base/nodes/Harvest/Harvest.node.ts @@ -6,6 +6,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -208,7 +209,7 @@ export class Harvest implements INodeType { const operation = this.getNodeParameter('operation', 0); let endpoint = ''; - let requestMethod = ''; + let requestMethod: IHttpRequestMethods; let body: IDataObject | Buffer; let qs: IDataObject; diff --git a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts index ead007d459..6ad5fbdbc7 100644 --- a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -13,7 +13,7 @@ import get from 'lodash/get'; export async function helpscoutApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function helpscoutApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -48,7 +48,7 @@ export async function helpscoutApiRequest( export async function helpscoutApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts b/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts index 59fa6c9617..bb6f977ad8 100644 --- a/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts @@ -5,18 +5,18 @@ import type { IExecutePaginationFunctions, IExecuteSingleFunctions, IHookFunctions, + IHttpRequestMethods, IHttpRequestOptions, ILoadOptionsFunctions, IN8nHttpFullResponse, INodeExecutionData, INodePropertyOptions, IPollFunctions, + IRequestOptions, IWebhookFunctions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import type { ToISOTimeOptions } from 'luxon'; import { DateTime } from 'luxon'; @@ -131,14 +131,14 @@ export async function highLevelApiRequest( | IPollFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}, ) { - let options: OptionsWithUri = { + let options: IRequestOptions = { method, body, qs, diff --git a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts index f277b4f9de..58194341bc 100644 --- a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, INodePropertyOptions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function homeAssistantApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -20,7 +20,7 @@ export async function homeAssistantApiRequest( ) { const credentials = await this.getCredentials('homeAssistantApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.accessToken}`, }, diff --git a/packages/nodes-base/nodes/HttpRequest/GenericFunctions.ts b/packages/nodes-base/nodes/HttpRequest/GenericFunctions.ts index 4227961724..397537a009 100644 --- a/packages/nodes-base/nodes/HttpRequest/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HttpRequest/GenericFunctions.ts @@ -1,5 +1,9 @@ -import type { IDataObject, INodeExecutionData, IOAuth2Options } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request-promise-native'; +import type { + IDataObject, + INodeExecutionData, + IOAuth2Options, + IRequestOptions, +} from 'n8n-workflow'; import set from 'lodash/set'; @@ -16,14 +20,16 @@ export const replaceNullValues = (item: INodeExecutionData) => { return item; }; -export function sanitizeUiMessage(request: OptionsWithUri, authDataKeys: IAuthDataSanitizeKeys) { +export function sanitizeUiMessage(request: IRequestOptions, authDataKeys: IAuthDataSanitizeKeys) { let sendRequest = request as unknown as IDataObject; // Protect browser from sending large binary data if (Buffer.isBuffer(sendRequest.body) && sendRequest.body.length > 250000) { sendRequest = { ...request, - body: `Binary data got replaced with this text. Original was a Buffer with a size of ${request.body.length} byte.`, + body: `Binary data got replaced with this text. Original was a Buffer with a size of ${ + (request.body as string).length + } byte.`, }; } diff --git a/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts b/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts index 6bf4e0a98f..3db86bcfe3 100644 --- a/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts @@ -8,10 +8,11 @@ import type { INodeTypeBaseDescription, INodeTypeDescription, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError, sleep, removeCircularRefs } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import type { IAuthDataSanitizeKeys } from '../GenericFunctions'; import { replaceNullValues, sanitizeUiMessage } from '../GenericFunctions'; interface OptionData { @@ -23,7 +24,7 @@ interface OptionDataParameters { [key: string]: OptionData; } -type OptionsWithUriKeys = keyof OptionsWithUri; +type IRequestOptionsKeys = keyof IRequestOptions; export class HttpRequestV1 implements INodeType { description: INodeTypeDescription; @@ -635,7 +636,7 @@ export class HttpRequestV1 implements INodeType { oAuth2Api = await this.getCredentials('oAuth2Api'); } catch {} - let requestOptions: OptionsWithUri & { useStream?: boolean }; + let requestOptions: IRequestOptions; let setUiParameter: IDataObject; const uiParameters: IDataObject = { @@ -661,7 +662,10 @@ export class HttpRequestV1 implements INodeType { let returnItems: INodeExecutionData[] = []; const requestPromises = []; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { - const requestMethod = this.getNodeParameter('requestMethod', itemIndex) as string; + const requestMethod = this.getNodeParameter( + 'requestMethod', + itemIndex, + ) as IHttpRequestMethods; const parametersAreJson = this.getNodeParameter('jsonParameters', itemIndex); const options = this.getNodeParameter('options', itemIndex, {}); @@ -688,7 +692,7 @@ export class HttpRequestV1 implements INodeType { uri: url, gzip: true, rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false), - }; + } satisfies IRequestOptions; if (fullResponse) { // @ts-ignore @@ -815,7 +819,7 @@ export class HttpRequestV1 implements INodeType { try { // @ts-ignore requestOptions[optionData.name] = JSON.parse( - requestOptions[optionData.name as OptionsWithUriKeys] as string, + requestOptions[optionData.name as IRequestOptionsKeys] as string, ); } catch (error) { throw new NodeOperationError( @@ -848,8 +852,8 @@ export class HttpRequestV1 implements INodeType { return newValue; } }; - requestOptions[optionName][parameterDataName] = computeNewValue( - requestOptions[optionName][parameterDataName], + requestOptions[optionName]![parameterDataName] = computeNewValue( + requestOptions[optionName]![parameterDataName], ); } else if (optionName === 'headers') { // @ts-ignore diff --git a/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts b/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts index 2c5d78f206..fbbf48f7a4 100644 --- a/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts @@ -3,15 +3,16 @@ import type { Readable } from 'stream'; import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, INodeExecutionData, INodeType, INodeTypeBaseDescription, INodeTypeDescription, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError, sleep, removeCircularRefs } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import type { IAuthDataSanitizeKeys } from '../GenericFunctions'; import { getOAuth2AdditionalParameters, @@ -28,7 +29,7 @@ interface OptionDataParameters { [key: string]: OptionData; } -type OptionsWithUriKeys = keyof OptionsWithUri; +type IRequestOptionsKeys = keyof IRequestOptions; export class HttpRequestV2 implements INodeType { description: INodeTypeDescription; @@ -675,7 +676,7 @@ export class HttpRequestV2 implements INodeType { } catch {} } - let requestOptions: OptionsWithUri & { useStream?: boolean }; + let requestOptions: IRequestOptions & { useStream?: boolean }; let setUiParameter: IDataObject; const uiParameters: IDataObject = { @@ -701,7 +702,10 @@ export class HttpRequestV2 implements INodeType { let returnItems: INodeExecutionData[] = []; const requestPromises = []; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { - const requestMethod = this.getNodeParameter('requestMethod', itemIndex) as string; + const requestMethod = this.getNodeParameter( + 'requestMethod', + itemIndex, + ) as IHttpRequestMethods; const parametersAreJson = this.getNodeParameter('jsonParameters', itemIndex); const options = this.getNodeParameter('options', itemIndex, {}); @@ -855,7 +859,7 @@ export class HttpRequestV2 implements INodeType { try { // @ts-ignore requestOptions[optionData.name] = JSON.parse( - requestOptions[optionData.name as OptionsWithUriKeys] as string, + requestOptions[optionData.name as IRequestOptionsKeys] as string, ); } catch (error) { throw new NodeOperationError( @@ -888,8 +892,8 @@ export class HttpRequestV2 implements INodeType { return newValue; } }; - requestOptions[optionName][parameterDataName] = computeNewValue( - requestOptions[optionName][parameterDataName], + requestOptions[optionName]![parameterDataName] = computeNewValue( + requestOptions[optionName]![parameterDataName], ); } else if (optionName === 'headers') { // @ts-ignore diff --git a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts index d8e765cb67..1dd00cd7ea 100644 --- a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts @@ -11,6 +11,8 @@ import type { IRequestOptionsSimplified, PaginationOptions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { @@ -22,8 +24,6 @@ import { sleep, } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request-promise-native'; - import type { BodyParameter, IAuthDataSanitizeKeys } from '../GenericFunctions'; import { binaryContentTypes, @@ -1223,8 +1223,7 @@ export class HttpRequestV3 implements INodeType { let nodeCredentialType: string | undefined; let genericCredentialType: string | undefined; - type RequestOptions = OptionsWithUri & { useStream?: boolean }; - let requestOptions: RequestOptions = { + let requestOptions: IRequestOptions = { uri: '', }; @@ -1279,7 +1278,7 @@ export class HttpRequestV3 implements INodeType { nodeCredentialType = this.getNodeParameter('nodeCredentialType', itemIndex) as string; } - const requestMethod = this.getNodeParameter('method', itemIndex) as string; + const requestMethod = this.getNodeParameter('method', itemIndex) as IHttpRequestMethods; const sendQuery = this.getNodeParameter('sendQuery', itemIndex, false) as boolean; const queryParameters = this.getNodeParameter( @@ -1465,10 +1464,10 @@ export class HttpRequestV3 implements INodeType { // Change the way data get send in case a different content-type than JSON got selected if (sendBody && ['PATCH', 'POST', 'PUT', 'GET'].includes(requestMethod)) { if (bodyContentType === 'multipart-form-data') { - requestOptions.formData = requestOptions.body; + requestOptions.formData = requestOptions.body as IDataObject; delete requestOptions.body; } else if (bodyContentType === 'form-urlencoded') { - requestOptions.form = requestOptions.body; + requestOptions.form = requestOptions.body as IDataObject; delete requestOptions.body; } else if (bodyContentType === 'binaryData') { const inputDataFieldName = this.getNodeParameter( @@ -1608,7 +1607,7 @@ export class HttpRequestV3 implements INodeType { authDataKeys.headers = Object.keys(customAuth.headers); } if (customAuth.body) { - requestOptions.body = { ...requestOptions.body, ...customAuth.body }; + requestOptions.body = { ...(requestOptions.body as IDataObject), ...customAuth.body }; authDataKeys.body = Object.keys(customAuth.body); } if (customAuth.qs) { diff --git a/packages/nodes-base/nodes/Hubspot/V1/GenericFunctions.ts b/packages/nodes-base/nodes/Hubspot/V1/GenericFunctions.ts index 758f8bad04..630ef73f0f 100644 --- a/packages/nodes-base/nodes/Hubspot/V1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hubspot/V1/GenericFunctions.ts @@ -1,12 +1,12 @@ -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -15,7 +15,7 @@ import moment from 'moment-timezone'; export async function hubspotApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, // tslint:disable-next-line:no-any body: any = {}, @@ -29,15 +29,15 @@ export async function hubspotApiRequest( authenticationMethod = 'developerApi'; } - const options: OptionsWithUri = { + const options = { method, qs: query, - headers: {}, + headers: {} as IDataObject, uri: uri || `https://api.hubapi.com${endpoint}`, body, json: true, useQuerystring: true, - }; + } satisfies IRequestOptions; try { if (authenticationMethod === 'apiKey') { @@ -48,7 +48,7 @@ export async function hubspotApiRequest( } else if (authenticationMethod === 'appToken') { const credentials = await this.getCredentials('hubspotAppToken'); - options.headers!.Authorization = `Bearer ${credentials.appToken}`; + options.headers.Authorization = `Bearer ${credentials.appToken}`; return await this.helpers.request(options); } else if (authenticationMethod === 'developerApi') { if (endpoint.includes('webhooks')) { @@ -79,7 +79,7 @@ export async function hubspotApiRequest( export async function hubspotApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, // tslint:disable-next-line:no-any body: any = {}, @@ -2002,7 +2002,7 @@ export async function validateCredentials( apiKey: string; }; - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'GET', headers: {}, uri: 'https://api.hubapi.com/deals/v1/deal/paged', diff --git a/packages/nodes-base/nodes/Hubspot/V2/GenericFunctions.ts b/packages/nodes-base/nodes/Hubspot/V2/GenericFunctions.ts index 2cd2e54782..c5b255ab6c 100644 --- a/packages/nodes-base/nodes/Hubspot/V2/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hubspot/V2/GenericFunctions.ts @@ -1,12 +1,12 @@ -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -15,7 +15,7 @@ import moment from 'moment-timezone'; export async function hubspotApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -28,7 +28,7 @@ export async function hubspotApiRequest( authenticationMethod = 'developerApi'; } - const options: OptionsWithUri = { + const options = { method, qs: query, headers: {}, @@ -36,7 +36,7 @@ export async function hubspotApiRequest( body, json: true, useQuerystring: true, - }; + } satisfies IRequestOptions; try { if (authenticationMethod === 'apiKey' || authenticationMethod === 'appToken') { @@ -71,7 +71,7 @@ export async function hubspotApiRequest( export async function hubspotApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -1991,7 +1991,7 @@ export async function validateCredentials( apiKey: string; }; - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'GET', headers: {}, uri: 'https://api.hubapi.com/deals/v1/deal/paged', diff --git a/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts b/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts index 823d6f879b..bd0479e0f0 100644 --- a/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function humanticAiApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function humanticAiApiRequest( ): Promise { try { const credentials = await this.getCredentials('humanticAiApi'); - let options: OptionsWithUri = { + let options = { headers: { 'Content-Type': 'application/json', }, @@ -29,7 +29,7 @@ export async function humanticAiApiRequest( body, uri: `https://api.humantic.ai/v1${resource}`, json: true, - }; + } satisfies IRequestOptions; options = Object.assign({}, options, option); options.qs.apikey = credentials.apiKey; diff --git a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts index 6d4f2bbd43..d78a2d204a 100644 --- a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts @@ -1,16 +1,17 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function hunterApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +21,7 @@ export async function hunterApiRequest( ): Promise { const credentials = await this.getCredentials('hunterApi'); qs = Object.assign({ api_key: credentials.apiKey }, qs); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, qs, body, @@ -45,7 +46,7 @@ export async function hunterApiRequest( export async function hunterApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts index b6c3c366cc..6ebbfd0642 100644 --- a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts @@ -1,18 +1,18 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function intercomApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, query?: IDataObject, @@ -25,7 +25,7 @@ export async function intercomApiRequest( { Authorization: `Bearer ${credentials.apiKey}`, Accept: 'application/json' }, ); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: headerWithAuthentication, method, qs: query, @@ -49,7 +49,7 @@ export async function intercomApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, propertyName: string, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts index b515bbdc55..76750e8fd9 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -21,7 +21,7 @@ export const eventID: { [key: string]: string } = { export async function invoiceNinjaApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query?: IDataObject, @@ -38,7 +38,7 @@ export async function invoiceNinjaApiRequest( const defaultUrl = version === 'v4' ? 'https://app.invoiceninja.com' : 'https://invoicing.co'; const baseUrl = credentials.url || defaultUrl; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, qs: query, uri: uri || `${baseUrl}/api/v1${endpoint}`, @@ -56,7 +56,7 @@ export async function invoiceNinjaApiRequest( export async function invoiceNinjaApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts index b809b43d6f..7ecc3cae02 100644 --- a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function iterableApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function iterableApiRequest( ): Promise { const credentials = await this.getCredentials('iterableApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', Api_Key: credentials.apiKey, @@ -48,7 +48,7 @@ export async function iterableApiRequest( export async function iterableApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts b/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts index 62d9afab2b..16bfe735b9 100644 --- a/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -15,7 +15,7 @@ export function tolerateTrailingSlash(baseUrl: string) { export async function jenkinsApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, uri: string, qs: IDataObject = {}, @@ -23,7 +23,7 @@ export async function jenkinsApiRequest( option: IDataObject = {}, ): Promise { const credentials = await this.getCredentials('jenkinsApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', }, diff --git a/packages/nodes-base/nodes/Jira/GenericFunctions.ts b/packages/nodes-base/nodes/Jira/GenericFunctions.ts index a646aa60bd..b5ea100ca1 100644 --- a/packages/nodes-base/nodes/Jira/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jira/GenericFunctions.ts @@ -1,12 +1,12 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeListSearchItems, INodePropertyOptions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -14,7 +14,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function jiraSoftwareCloudApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, query?: IDataObject, uri?: string, @@ -33,7 +33,7 @@ export async function jiraSoftwareCloudApiRequest( credentialType = 'jiraSoftwareCloudApi'; } - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -74,7 +74,7 @@ export async function jiraSoftwareCloudApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, query: IDataObject = {}, ): Promise { diff --git a/packages/nodes-base/nodes/JotForm/GenericFunctions.ts b/packages/nodes-base/nodes/JotForm/GenericFunctions.ts index c831a0b773..bd6292840d 100644 --- a/packages/nodes-base/nodes/JotForm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/JotForm/GenericFunctions.ts @@ -1,9 +1,10 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -11,7 +12,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function jotformApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +21,7 @@ export async function jotformApiRequest( option: IDataObject = {}, ): Promise { const credentials = await this.getCredentials('jotFormApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { APIKEY: credentials.apiKey, 'Content-Type': 'application/x-www-form-urlencoded', diff --git a/packages/nodes-base/nodes/Keap/GenericFunctions.ts b/packages/nodes-base/nodes/Keap/GenericFunctions.ts index 15adc3ea8a..896c4449a9 100644 --- a/packages/nodes-base/nodes/Keap/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Keap/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -14,7 +14,7 @@ import { snakeCase } from 'change-case'; export async function keapApiRequest( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -23,7 +23,7 @@ export async function keapApiRequest( headers: IDataObject = {}, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -51,7 +51,7 @@ export async function keapApiRequest( export async function keapApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Keap/Keap.node.ts b/packages/nodes-base/nodes/Keap/Keap.node.ts index 746e8b9634..8c358f5fc6 100644 --- a/packages/nodes-base/nodes/Keap/Keap.node.ts +++ b/packages/nodes-base/nodes/Keap/Keap.node.ts @@ -604,7 +604,7 @@ export class Keap implements INodeType { //https://developer.infusionsoft.com/docs/rest/#!/E-Commerce/getOrderUsingGET if (operation === 'get') { const orderId = parseInt(this.getNodeParameter('orderId', i) as string, 10); - responseData = await keapApiRequest.call(this, 'get', `/orders/${orderId}`); + responseData = await keapApiRequest.call(this, 'GET', `/orders/${orderId}`); } //https://developer.infusionsoft.com/docs/rest/#!/E-Commerce/listOrdersUsingGET if (operation === 'getAll') { @@ -649,7 +649,7 @@ export class Keap implements INodeType { //https://developer.infusionsoft.com/docs/rest/#!/Product/retrieveProductUsingGET if (operation === 'get') { const productId = this.getNodeParameter('productId', i) as string; - responseData = await keapApiRequest.call(this, 'get', `/products/${productId}`); + responseData = await keapApiRequest.call(this, 'GET', `/products/${productId}`); } //https://developer.infusionsoft.com/docs/rest/#!/Product/listProductsUsingGET if (operation === 'getAll') { diff --git a/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts b/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts index e668293b68..b1ee217308 100644 --- a/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts @@ -4,6 +4,7 @@ import type { IDataObject, IHookFunctions, JsonObject, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -23,7 +24,7 @@ export async function kitemakerRequest( body, uri: 'https://toil.kitemaker.co/developers/graphql', json: true, - }; + } satisfies IRequestOptions; const responseData = await this.helpers.request.call(this, options); diff --git a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts index 0a786c4019..8a587a9390 100644 --- a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts @@ -3,10 +3,10 @@ import type { IHookFunctions, IDataObject, ILoadOptionsFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import { capitalCase } from 'change-case'; /** @@ -14,13 +14,13 @@ import { capitalCase } from 'change-case'; */ export async function lemlistApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, option: IDataObject = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, uri: `https://api.lemlist.com/api${endpoint}`, @@ -49,7 +49,7 @@ export async function lemlistApiRequest( */ export async function lemlistApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject = {}, ) { diff --git a/packages/nodes-base/nodes/Line/GenericFunctions.ts b/packages/nodes-base/nodes/Line/GenericFunctions.ts index ddb36adf8e..d779bdd3b9 100644 --- a/packages/nodes-base/nodes/Line/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Line/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function lineApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -19,7 +19,7 @@ export async function lineApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/Linear/GenericFunctions.ts b/packages/nodes-base/nodes/Linear/GenericFunctions.ts index 3ba7c9deba..886685458d 100644 --- a/packages/nodes-base/nodes/Linear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Linear/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, @@ -9,6 +7,7 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -25,7 +24,7 @@ export async function linearApiRequest( const endpoint = 'https://api.linear.app/graphql'; const authenticationMethod = this.getNodeParameter('authentication', 0, 'apiToken') as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -76,7 +75,7 @@ export async function validateCredentials( ): Promise { const credentials = decryptedCredentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', Authorization: credentials.apiKey, diff --git a/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts b/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts index 50e7a31cd3..ef41a88061 100644 --- a/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function lingvaNexApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function lingvaNexApiRequest( ): Promise { try { const credentials = await this.getCredentials('lingvaNexApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.apiKey}`, }, diff --git a/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts b/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts index 160780d18d..0d914d9706 100644 --- a/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts +++ b/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUrl } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; function resolveHeaderData(fullResponse: any) { @@ -18,7 +18,7 @@ function resolveHeaderData(fullResponse: any) { export async function linkedInApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -33,7 +33,7 @@ export async function linkedInApiRequest( const baseUrl = 'https://api.linkedin.com'; - let options: OptionsWithUrl = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'X-Restli-Protocol-Version': '2.0.0', diff --git a/packages/nodes-base/nodes/LoneScale/GenericFunctions.ts b/packages/nodes-base/nodes/LoneScale/GenericFunctions.ts index df82c7e060..b237024c81 100644 --- a/packages/nodes-base/nodes/LoneScale/GenericFunctions.ts +++ b/packages/nodes-base/nodes/LoneScale/GenericFunctions.ts @@ -1,18 +1,18 @@ -import type { OptionsWithUri } from 'request'; - import { ApplicationError, + type IHttpRequestMethods, type IDataObject, type IExecuteFunctions, type IHookFunctions, type ILoadOptionsFunctions, type IWebhookFunctions, + type IRequestOptions, } from 'n8n-workflow'; import { BASE_URL } from './constants'; export async function lonescaleApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, query: IDataObject = {}, @@ -20,7 +20,7 @@ export async function lonescaleApiRequest( ) { const endpoint = `${BASE_URL}`; const credentials = await this.getCredentials('loneScaleApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', 'X-API-KEY': credentials?.apiKey, diff --git a/packages/nodes-base/nodes/Magento/GenericFunctions.ts b/packages/nodes-base/nodes/Magento/GenericFunctions.ts index 3e3071cc75..f4255a3194 100644 --- a/packages/nodes-base/nodes/Magento/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Magento/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, @@ -9,13 +7,15 @@ import type { INodeProperties, INodePropertyOptions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { ApplicationError, NodeApiError } from 'n8n-workflow'; import type { Filter, Address, Search, FilterGroup, ProductAttribute } from './types'; export async function magentoApiRequest( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -26,7 +26,7 @@ export async function magentoApiRequest( ): Promise { const credentials = await this.getCredentials('magento2Api'); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, body, qs, @@ -49,7 +49,7 @@ export async function magentoApiRequest( export async function magentoApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts index e582627f9a..ae014ceed5 100644 --- a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts @@ -1,18 +1,18 @@ -import type { OptionsWithUri } from 'request'; - import { ApplicationError } from 'n8n-workflow'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, } from 'n8n-workflow'; export async function mailCheckApiRequest( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -23,7 +23,7 @@ export async function mailCheckApiRequest( ): Promise { const credentials = await this.getCredentials('mailcheckApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${credentials.apiKey}`, diff --git a/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts b/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts index 7301e6f984..3c9627ef7d 100644 --- a/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUrl } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -14,7 +14,7 @@ async function getMetadata( oauthTokenData: IDataObject, ) { const credentials = await this.getCredentials('mailchimpOAuth2Api'); - const options: OptionsWithUrl = { + const options: IRequestOptions = { headers: { Accept: 'application/json', Authorization: `OAuth ${oauthTokenData.access_token}`, @@ -29,7 +29,7 @@ async function getMetadata( export async function mailchimpApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, qs: IDataObject = {}, @@ -39,7 +39,7 @@ export async function mailchimpApiRequest( const host = 'api.mailchimp.com/3.0'; - const options: OptionsWithUrl = { + const options: IRequestOptions = { headers: { Accept: 'application/json', }, @@ -84,7 +84,7 @@ export async function mailchimpApiRequest( export async function mailchimpApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, endpoint: string, - method: string, + method: IHttpRequestMethods, propertyName: string, body: any = {}, diff --git a/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts b/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts index b4486ace3d..2459f349d1 100644 --- a/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function mailerliteApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -20,7 +20,7 @@ export async function mailerliteApiRequest( ): Promise { const credentials = await this.getCredentials('mailerLiteApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'X-MailerLite-ApiKey': credentials.apiKey, }, @@ -43,7 +43,7 @@ export async function mailerliteApiRequest( export async function mailerliteApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts index 9adcfe636b..24e151d349 100644 --- a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts +++ b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts @@ -5,6 +5,7 @@ import type { INodeType, INodeTypeDescription, JsonObject, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -172,7 +173,7 @@ export class Mailgun implements INodeType { formData, uri: `https://${credentials.apiDomain}/v3/${credentials.emailDomain}/messages`, json: true, - }; + } satisfies IRequestOptions; let responseData; diff --git a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts index d72857a08c..d25b301b2b 100644 --- a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts @@ -1,15 +1,15 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, IHookFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; export async function mailjetApiRequest( this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -34,7 +34,7 @@ export async function mailjetApiRequest( credentialType = 'mailjetSmsApi'; } - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -55,7 +55,7 @@ export async function mailjetApiRequest( export async function mailjetApiRequestAllItems( this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts b/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts index 7883c87d35..b2b08ce01a 100644 --- a/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts @@ -1,10 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import map from 'lodash/map'; import type { + IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -12,11 +13,11 @@ import { NodeApiError } from 'n8n-workflow'; export async function mandrillApiRequest( this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, resource: string, - method: string, + method: IHttpRequestMethods, action: string, body: any = {}, - headers?: object, + headers?: IDataObject, ): Promise { const credentials = await this.getCredentials('mandrillApi'); @@ -24,7 +25,7 @@ export async function mandrillApiRequest( const endpoint = 'mandrillapp.com/api/1.0'; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers, method, uri: `https://${endpoint}${resource}${action}.json`, diff --git a/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts b/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts index c20a765791..6e8511967a 100644 --- a/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts @@ -1,11 +1,15 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function marketstackApiRequest( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -13,7 +17,7 @@ export async function marketstackApiRequest( const credentials = await this.getCredentials('marketstackApi'); const protocol = credentials.useHttps ? 'https' : 'http'; // Free API does not support HTTPS - const options: OptionsWithUri = { + const options: IRequestOptions = { method, uri: `${protocol}://api.marketstack.com/v1${endpoint}`, qs: { @@ -36,7 +40,7 @@ export async function marketstackApiRequest( export async function marketstackApiRequestAllItems( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts index 7747921ebe..cb8370f6bd 100644 --- a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts @@ -1,9 +1,9 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -12,14 +12,14 @@ import { v4 as uuid } from 'uuid'; export async function matrixApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: string | object = {}, - query: object = {}, + query: IDataObject = {}, headers: IDataObject | undefined = undefined, option: IDataObject = {}, ) { - let options: OptionsWithUri = { + let options: IRequestOptions = { method, headers: headers || { 'Content-Type': 'application/json; charset=utf-8', diff --git a/packages/nodes-base/nodes/Mautic/GenericFunctions.ts b/packages/nodes-base/nodes/Mautic/GenericFunctions.ts index f332d5d6a0..076099fbef 100644 --- a/packages/nodes-base/nodes/Mautic/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mautic/GenericFunctions.ts @@ -2,15 +2,16 @@ import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; export async function mauticApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -19,7 +20,7 @@ export async function mauticApiRequest( ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'credentials') as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, qs: query, @@ -67,7 +68,7 @@ export async function mauticApiRequest( export async function mauticApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Medium/GenericFunctions.ts b/packages/nodes-base/nodes/Medium/GenericFunctions.ts index 11dae638ff..5952c07485 100644 --- a/packages/nodes-base/nodes/Medium/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Medium/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function mediumApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -20,7 +20,7 @@ export async function mediumApiRequest( ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: { Accept: 'application/json', diff --git a/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts b/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts index 8ad09e74bb..b8183d08c3 100644 --- a/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts @@ -1,6 +1,11 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IHookFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IHookFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -9,14 +14,14 @@ import { NodeApiError } from 'n8n-workflow'; */ export async function messageBirdApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject, query: IDataObject = {}, ): Promise { const credentials = await this.getCredentials('messageBirdApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Accept: 'application/json', Authorization: `AccessKey ${credentials.accessKey}`, diff --git a/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts b/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts index b9245753f6..c4a78b40bd 100644 --- a/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts +++ b/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -290,7 +291,7 @@ export class MessageBird implements INodeType { // For Query string let qs: IDataObject; - let requestMethod; + let requestMethod: IHttpRequestMethods; let requestPath; for (let i = 0; i < items.length; i++) { diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts index bdb2987ced..c4ec696878 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, @@ -7,12 +5,14 @@ import type { INodeProperties, INodePropertyOptions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -25,7 +25,7 @@ export async function microsoftApiRequest( region: string; }; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', accept: 'application/json', @@ -54,7 +54,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/addTable.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/addTable.test.ts index 85529fab1b..44165a998b 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/addTable.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/addTable.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'POST') { return { style: 'TableStyleMedium2', diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/append.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/append.test.ts index ce96554e49..7762ed4894 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/append.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/append.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string, resource: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) { if (method === 'GET') { return { value: [ diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/convertToRange.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/convertToRange.test.ts index 987410fe68..636d991408 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/convertToRange.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/convertToRange.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'POST') { return { address: 'Sheet4!A1:D5', diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/deleteTable.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/deleteTable.test.ts index 9865e38e17..15f7943c8e 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/deleteTable.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/deleteTable.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'DELETE') { return; } diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/getRows.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/getRows.test.ts index 32485b683d..78366e9164 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/getRows.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/getRows.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'GET') { return { value: [ diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/lookup.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/lookup.test.ts index 0a415ea2a5..ef2b667d5b 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/lookup.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/table/lookup.test.ts @@ -12,7 +12,7 @@ jest.mock('../../../../v2/transport', () => { ...originalModule, microsoftApiRequestAllItemsSkip: jest.fn(async function ( _property: string, - _method: string, + _method: IHttpRequestMethods, endpoint: string, ) { if (endpoint.includes('columns')) { diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/addWorksheet.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/addWorksheet.test.ts index 861cf1ae8a..b939b19b97 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/addWorksheet.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/addWorksheet.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string, resource: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) { if (method === 'POST' && resource.includes('createSession')) { return { id: 12345, diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/deleteWorkbook.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/deleteWorkbook.test.ts index fa02581e73..126dad3093 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/deleteWorkbook.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/deleteWorkbook.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'DELETE') { return; } diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/getAll.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/getAll.test.ts index 66eb450ad3..cdb1138e0f 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/getAll.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/workbook/getAll.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'GET') { return { value: [ diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/append.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/append.test.ts index 1f3e4fe306..d6fc5b4cab 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/append.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/append.test.ts @@ -5,7 +5,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string, resource: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) { if (method === 'GET' && resource.includes('usedRange')) { return { address: 'Sheet4!A1:D6', diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/clear.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/clear.test.ts index aba4f434ea..dbb3a0d96d 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/clear.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/clear.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'POST') { return { values: [ diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/deleteWorksheet.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/deleteWorksheet.test.ts index b019735289..e53b95d668 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/deleteWorksheet.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/deleteWorksheet.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'DELETE') { return { values: [ diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/getAll.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/getAll.test.ts index 79fc34ed4d..445ca6f434 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/getAll.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/getAll.test.ts @@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) { if (method === 'GET') { return { value: [ diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/readRows.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/readRows.test.ts index 99ee7aabe5..16b90626e8 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/readRows.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/readRows.test.ts @@ -5,7 +5,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string, resource: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) { { if (method === 'GET' && resource.includes('usedRange')) { return { diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/update.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/update.test.ts index a3c4c71d81..4da95e1302 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/update.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/update.test.ts @@ -5,7 +5,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string, resource: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) { if (method === 'GET' && resource.includes('usedRange')) { return { address: 'Sheet4!A1:D6', diff --git a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/upsert.test.ts b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/upsert.test.ts index 429ea3b1ca..d370fcbdab 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/upsert.test.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/test/v2/node/worksheet/upsert.test.ts @@ -5,7 +5,7 @@ jest.mock('../../../../v2/transport', () => { const originalModule = jest.requireActual('../../../../v2/transport'); return { ...originalModule, - microsoftApiRequest: jest.fn(async function (method: string, resource: string) { + microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) { if (method === 'GET' && resource.includes('usedRange')) { return { address: 'Sheet4!A1:D6', diff --git a/packages/nodes-base/nodes/Microsoft/Excel/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Excel/v1/GenericFunctions.ts index 682eed399f..de35822438 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/v1/GenericFunctions.ts @@ -1,15 +1,16 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -17,7 +18,7 @@ export async function microsoftApiRequest( uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -41,7 +42,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -68,7 +69,7 @@ export async function microsoftApiRequestAllItems( export async function microsoftApiRequestAllItemsSkip( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Microsoft/Excel/v2/transport/index.ts b/packages/nodes-base/nodes/Microsoft/Excel/v2/transport/index.ts index 843ebf0ed3..61d0c4b1c4 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/v2/transport/index.ts @@ -1,22 +1,23 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -39,7 +40,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, query: IDataObject = {}, @@ -65,7 +66,7 @@ export async function microsoftApiRequestAllItems( export async function microsoftApiRequestAllItemsSkip( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts index fd6b94a866..dbc1c40661 100644 --- a/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts @@ -1,11 +1,15 @@ -import type { IExecuteFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IDataObject, + JsonObject, + IRequestOptions, + IHttpRequestMethods, +} from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - export async function msGraphSecurityApiRequest( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -19,7 +23,7 @@ export async function msGraphSecurityApiRequest( }; }; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${access_token}`, }, diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts index ce8641818b..cb88bd0a5b 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -19,7 +19,7 @@ export async function microsoftApiRequest( headers: IDataObject = {}, option: IDataObject = { json: true }, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -49,7 +49,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -76,7 +76,7 @@ export async function microsoftApiRequestAllItems( export async function microsoftApiRequestAllItemsSkip( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Outlook/v1/GenericFunctions.ts index 87aea4dfb6..b29c295f98 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/v1/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { BINARY_ENCODING, NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -28,7 +28,7 @@ export async function microsoftApiRequest( apiUrl = `https://graph.microsoft.com/v1.0/users/${credentials.userPrincipalName}${resource}`; } - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -57,7 +57,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -90,7 +90,7 @@ export async function microsoftApiRequestAllItems( export async function microsoftApiRequestAllItemsSkip( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/v2/transport/index.ts b/packages/nodes-base/nodes/Microsoft/Outlook/v2/transport/index.ts index f6bf061295..772e519c05 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/v2/transport/index.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - -import { - type IDataObject, - type IExecuteFunctions, - type IExecuteSingleFunctions, - type ILoadOptionsFunctions, - type INodeExecutionData, +import type { + IHttpRequestMethods, + IRequestOptions, + IDataObject, + IExecuteFunctions, + IExecuteSingleFunctions, + ILoadOptionsFunctions, + INodeExecutionData, } from 'n8n-workflow'; import { prepareApiError } from '../helpers/utils'; export async function microsoftApiRequest( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -27,7 +27,7 @@ export async function microsoftApiRequest( apiUrl = `https://graph.microsoft.com/v1.0/users/${credentials.userPrincipalName}${resource}`; } - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -77,7 +77,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Microsoft/Teams/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Teams/v1/GenericFunctions.ts index b54a1c0f7d..0449ead6cb 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/v1/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -18,7 +18,7 @@ export async function microsoftApiRequest( uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -42,7 +42,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -69,7 +69,7 @@ export async function microsoftApiRequestAllItems( export async function microsoftApiRequestAllItemsSkip( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Microsoft/Teams/v2/transport/index.ts b/packages/nodes-base/nodes/Microsoft/Teams/v2/transport/index.ts index 5ae6a42566..150c82b6d3 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/v2/transport/index.ts @@ -1,24 +1,24 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { capitalize } from '../../../../../utils/utilities'; export async function microsoftApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -54,7 +54,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -81,7 +81,7 @@ export async function microsoftApiRequestAllItems( export async function microsoftApiRequestAllItemsSkip( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts index a6fcff7263..4f5e4deb71 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -18,7 +18,7 @@ export async function microsoftApiRequest( _headers: IDataObject = {}, option: IDataObject = { json: true }, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -45,7 +45,7 @@ export async function microsoftApiRequest( export async function microsoftApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, @@ -71,7 +71,7 @@ export async function microsoftApiRequestAllItems( export async function microsoftApiRequestAllItemsSkip( this: IExecuteFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Mindee/GenericFunctions.ts b/packages/nodes-base/nodes/Mindee/GenericFunctions.ts index b2024d624a..35b5e19742 100644 --- a/packages/nodes-base/nodes/Mindee/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mindee/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function mindeeApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, qs: IDataObject = {}, @@ -33,7 +33,7 @@ export async function mindeeApiRequest( ? `https://api.mindee.net/products${path}` : `https://api.mindee.net/v1/products/mindee${path}`; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, body, diff --git a/packages/nodes-base/nodes/Misp/GenericFunctions.ts b/packages/nodes-base/nodes/Misp/GenericFunctions.ts index 2034d8ee8d..a0e3e03597 100644 --- a/packages/nodes-base/nodes/Misp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Misp/GenericFunctions.ts @@ -4,16 +4,16 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import type { MispCredentials } from './types'; export async function mispApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -22,7 +22,7 @@ export async function mispApiRequest( 'mispApi', )) as MispCredentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, diff --git a/packages/nodes-base/nodes/Mocean/GenericFunctions.ts b/packages/nodes-base/nodes/Mocean/GenericFunctions.ts index 87868fc660..b6ef63be09 100644 --- a/packages/nodes-base/nodes/Mocean/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mocean/GenericFunctions.ts @@ -1,4 +1,10 @@ -import type { IExecuteFunctions, IHookFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IHookFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -7,7 +13,7 @@ import { NodeApiError } from 'n8n-workflow'; */ export async function moceanApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/Mocean/Mocean.node.ts b/packages/nodes-base/nodes/Mocean/Mocean.node.ts index e027da5054..137b47385c 100644 --- a/packages/nodes-base/nodes/Mocean/Mocean.node.ts +++ b/packages/nodes-base/nodes/Mocean/Mocean.node.ts @@ -8,6 +8,7 @@ import type { INodeType, INodeTypeDescription, JsonObject, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -220,7 +221,7 @@ export class Mocean implements INodeType { let endpoint: string; let operation: string; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let resource: string; let text: string; let dlrUrl: string; diff --git a/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts b/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts index 07f017ff1b..ff993c7d1c 100644 --- a/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, @@ -7,6 +5,7 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -19,7 +18,7 @@ export async function mondayComApiRequest( ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0) as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'API-Version': '2023-10', 'Content-Type': 'application/json', diff --git a/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts b/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts index fc788a9170..e8f9e66778 100644 --- a/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts @@ -3,16 +3,16 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import type { LoaderGetResponse } from './types'; export async function monicaCrmApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -33,7 +33,7 @@ export async function monicaCrmApiRequest( baseUrl = credentials.domain; } - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.apiToken}`, }, @@ -61,7 +61,7 @@ export async function monicaCrmApiRequest( export async function monicaCrmApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Msg91/GenericFunctions.ts b/packages/nodes-base/nodes/Msg91/GenericFunctions.ts index cabc018cf6..35ef4e00ac 100644 --- a/packages/nodes-base/nodes/Msg91/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Msg91/GenericFunctions.ts @@ -1,4 +1,10 @@ -import type { IExecuteFunctions, IHookFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IHookFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -7,7 +13,7 @@ import { NodeApiError } from 'n8n-workflow'; */ export async function msg91ApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/Msg91/Msg91.node.ts b/packages/nodes-base/nodes/Msg91/Msg91.node.ts index dd099e2f70..6f62c5eec1 100644 --- a/packages/nodes-base/nodes/Msg91/Msg91.node.ts +++ b/packages/nodes-base/nodes/Msg91/Msg91.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -123,7 +124,7 @@ export class Msg91 implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; for (let i = 0; i < items.length; i++) { diff --git a/packages/nodes-base/nodes/N8n/GenericFunctions.ts b/packages/nodes-base/nodes/N8n/GenericFunctions.ts index 585030ef46..e190d8abb0 100644 --- a/packages/nodes-base/nodes/N8n/GenericFunctions.ts +++ b/packages/nodes-base/nodes/N8n/GenericFunctions.ts @@ -5,21 +5,22 @@ import type { IExecutePaginationFunctions, IExecuteSingleFunctions, IHookFunctions, + IHttpRequestMethods, IHttpRequestOptions, ILoadOptionsFunctions, INodeExecutionData, + IRequestOptions, JsonObject, PreSendAction, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; /** * A custom API request function to be used with the resourceLocator lookup queries. */ export async function apiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, query?: IDataObject, @@ -34,7 +35,7 @@ export async function apiRequest( const credentials = (await this.getCredentials('n8nApi')) as N8nApiCredentials; const baseUrl = credentials.baseUrl; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs: query, @@ -54,7 +55,7 @@ export async function apiRequest( export async function apiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, query?: IDataObject, diff --git a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts index c20cb3856d..0b69c55a6f 100644 --- a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts @@ -1,11 +1,16 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IHookFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IHookFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function nasaApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, option: IDataObject = {}, @@ -15,7 +20,7 @@ export async function nasaApiRequest( qs.api_key = credentials.api_key as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, qs, uri: uri || `https://api.nasa.gov${endpoint}`, @@ -36,7 +41,7 @@ export async function nasaApiRequest( export async function nasaApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, query: IDataObject = {}, ): Promise { diff --git a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts index dd257e4fcc..1c17f44b30 100644 --- a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function netlifyApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -19,7 +19,7 @@ export async function netlifyApiRequest( uri?: string, option: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: { 'Content-Type': 'application/json', @@ -51,7 +51,7 @@ export async function netlifyApiRequest( export async function netlifyRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts index 159ece886f..882df0d658 100644 --- a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts @@ -1,6 +1,11 @@ -import { NodeOperationError, type IExecuteFunctions, type IHookFunctions } from 'n8n-workflow'; - -import type { OptionsWithUri } from 'request'; +import { + NodeOperationError, + type IExecuteFunctions, + type IHookFunctions, + type IHttpRequestMethods, + type IRequestOptions, + type IDataObject, +} from 'n8n-workflow'; /** * Make an API request to NextCloud @@ -8,12 +13,12 @@ import type { OptionsWithUri } from 'request'; */ export async function nextCloudApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object | string | Buffer, - headers?: object, + headers?: IDataObject, encoding?: null | undefined, - query?: object, + query?: IDataObject, ) { const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); @@ -27,7 +32,7 @@ export async function nextCloudApiRequest( credentials = (await this.getCredentials('nextCloudOAuth2Api')) as { webDavUrl: string }; } - const options: OptionsWithUri = { + const options: IRequestOptions = { headers, method, body, diff --git a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts index 510dffbc0e..83df6b9795 100644 --- a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts +++ b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts @@ -3,6 +3,7 @@ import type { IBinaryKeyData, IDataObject, IExecuteFunctions, + IHttpRequestMethods, INodeExecutionData, INodeType, INodeTypeDescription, @@ -874,7 +875,7 @@ export class NextCloud implements INodeType { const operation = this.getNodeParameter('operation', 0); let endpoint = ''; - let requestMethod = ''; + let requestMethod: IHttpRequestMethods = 'GET'; let responseData: any; let body: string | Buffer | IDataObject = ''; @@ -914,14 +915,14 @@ export class NextCloud implements INodeType { // create // ---------------------------------- - requestMethod = 'MKCOL'; + requestMethod = 'MKCOL' as IHttpRequestMethods; endpoint = this.getNodeParameter('path', i) as string; } else if (operation === 'list') { // ---------------------------------- // list // ---------------------------------- - requestMethod = 'PROPFIND'; + requestMethod = 'PROPFIND' as IHttpRequestMethods; endpoint = this.getNodeParameter('path', i) as string; } } @@ -932,7 +933,7 @@ export class NextCloud implements INodeType { // copy // ---------------------------------- - requestMethod = 'COPY'; + requestMethod = 'COPY' as IHttpRequestMethods; endpoint = this.getNodeParameter('path', i) as string; const toPath = this.getNodeParameter('toPath', i) as string; headers.Destination = `${credentials.webDavUrl}/${encodeURI(toPath)}`; @@ -948,7 +949,7 @@ export class NextCloud implements INodeType { // move // ---------------------------------- - requestMethod = 'MOVE'; + requestMethod = 'MOVE' as IHttpRequestMethods; endpoint = this.getNodeParameter('path', i) as string; const toPath = this.getNodeParameter('toPath', i) as string; headers.Destination = `${credentials.webDavUrl}/${encodeURI(toPath)}`; diff --git a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts index 8900cc04e3..87afe701fb 100644 --- a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts @@ -1,14 +1,14 @@ -import type { OptionsWithUri } from 'request'; - import type { IBinaryKeyData, IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, IPairedItemData, IPollFunctions, + IRequestOptions, } from 'n8n-workflow'; import { jsonParse, NodeOperationError } from 'n8n-workflow'; @@ -26,7 +26,7 @@ interface IAttachment { */ export async function apiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, query?: IDataObject, @@ -48,7 +48,7 @@ export async function apiRequest( uri = baseUrl.endsWith('/') ? `${baseUrl.slice(0, -1)}${endpoint}` : `${baseUrl}${endpoint}`; } - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs: query, @@ -75,7 +75,7 @@ export async function apiRequest( */ export async function apiRequestAllItems( this: IHookFunctions | IExecuteFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts b/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts index 4fffdaaa42..bfe3f4c090 100644 --- a/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts +++ b/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts @@ -2,6 +2,7 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, INodeType, @@ -279,7 +280,7 @@ export class NocoDB implements INodeType { const operation = this.getNodeParameter('operation', 0); let returnAll = false; - let requestMethod = ''; + let requestMethod: IHttpRequestMethods = 'GET'; let qs: IDataObject = {}; diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index 3305e4418d..c20a3b8de8 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IBinaryKeyData, IDataObject, IDisplayOptions, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, INodeProperties, IPairedItemData, IPollFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -45,7 +45,7 @@ const apiVersion: { [key: number]: string } = { export async function notionApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -54,7 +54,7 @@ export async function notionApiRequest( option: IDataObject = {}, ): Promise { try { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Notion-Version': apiVersion[this.getNode().typeVersion], }, @@ -80,7 +80,7 @@ export async function notionApiRequest( export async function notionApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts index 3bd8a214d1..53634b6438 100644 --- a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts @@ -1,11 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -109,7 +108,7 @@ export async function odooJSONRPCRequest( url: string, ): Promise { try { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'User-Agent': 'n8n', Connection: 'keep-alive', diff --git a/packages/nodes-base/nodes/Odoo/Odoo.node.ts b/packages/nodes-base/nodes/Odoo/Odoo.node.ts index 4b271efa25..2df531dc54 100644 --- a/packages/nodes-base/nodes/Odoo/Odoo.node.ts +++ b/packages/nodes-base/nodes/Odoo/Odoo.node.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ICredentialsDecrypted, @@ -11,6 +9,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; import { deepCopy } from 'n8n-workflow'; @@ -256,7 +255,7 @@ export class Odoo implements INodeType { id: Math.floor(Math.random() * 100), }; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'User-Agent': 'n8n', Connection: 'keep-alive', diff --git a/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts b/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts index b4c0ed746f..f8efd5ddc1 100644 --- a/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts @@ -1,11 +1,15 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function oneSimpleApiRequest( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -15,7 +19,7 @@ export async function oneSimpleApiRequest( const credentials = await this.getCredentials('oneSimpleApi'); const outputFormat = 'json'; - let options: OptionsWithUri = { + let options: IRequestOptions = { method, body, qs, diff --git a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts index 998a090cdc..87c1b0be28 100644 --- a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts @@ -2,20 +2,20 @@ import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodePropertyOptions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import moment from 'moment-timezone'; export async function onfleetApiRequest( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -25,7 +25,7 @@ export async function onfleetApiRequest( ): Promise { const credentials = await this.getCredentials('onfleetApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', 'User-Agent': 'n8n-onfleet', @@ -50,7 +50,7 @@ export async function onfleetApiRequest( export async function onfleetApiRequestAllItems( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts b/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts index eb79ebf7a0..16c135383c 100644 --- a/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts +++ b/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts @@ -7,9 +7,9 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import { taskFields, taskOperations } from './descriptions/TaskDescription'; import { destinationFields, destinationOperations } from './descriptions/DestinationDescription'; @@ -141,7 +141,7 @@ export class Onfleet implements INodeType { ): Promise { const credentials = credential.data as IDataObject; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', 'User-Agent': 'n8n-onfleet', diff --git a/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts b/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts index 9e61d9d02c..33b7906adf 100644 --- a/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts +++ b/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function openThesaurusApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function openThesaurusApiRequest( option: IDataObject = {}, ): Promise { try { - let options: OptionsWithUri = { + let options = { headers: { 'User-Agent': 'https://n8n.io', }, @@ -29,7 +29,7 @@ export async function openThesaurusApiRequest( body, uri: uri || `https://www.openthesaurus.de${resource}`, json: true, - }; + } satisfies IRequestOptions; options = Object.assign({}, options, option); options.qs.format = 'application/json'; diff --git a/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts b/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts index 77ffe88abc..f1f40ffc32 100644 --- a/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts +++ b/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts @@ -5,11 +5,10 @@ import type { INodeType, INodeTypeDescription, JsonObject, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - export class OpenWeatherMap implements INodeType { description: INodeTypeDescription = { displayName: 'OpenWeatherMap', @@ -260,7 +259,7 @@ export class OpenWeatherMap implements INodeType { ); } - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'GET', qs, uri: `https://api.openweathermap.org/data/2.5/${endpoint}`, diff --git a/packages/nodes-base/nodes/Orbit/GenericFunctions.ts b/packages/nodes-base/nodes/Orbit/GenericFunctions.ts index 459d8b27f6..7759f248ef 100644 --- a/packages/nodes-base/nodes/Orbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Orbit/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { JsonObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, IDataObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -13,7 +13,7 @@ import type { IRelation } from './Interfaces'; export async function orbitApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -23,7 +23,7 @@ export async function orbitApiRequest( ): Promise { try { const credentials = await this.getCredentials('orbitApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.accessToken}`, }, @@ -86,7 +86,7 @@ export function resolveMember(responseData: IRelation) { export async function orbitApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Oura/GenericFunctions.ts b/packages/nodes-base/nodes/Oura/GenericFunctions.ts index 1987a1c01c..9fb9691822 100644 --- a/packages/nodes-base/nodes/Oura/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Oura/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function ouraApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -19,7 +19,7 @@ export async function ouraApiRequest( option: IDataObject = {}, ) { const credentials = await this.getCredentials('ouraApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.accessToken}`, }, diff --git a/packages/nodes-base/nodes/Paddle/GenericFunctions.ts b/packages/nodes-base/nodes/Paddle/GenericFunctions.ts index 8dedc3a49b..ea6808cf1c 100644 --- a/packages/nodes-base/nodes/Paddle/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Paddle/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { JsonObject, IExecuteFunctions, @@ -7,13 +5,15 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, IDataObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function paddleApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, _query?: IDataObject, @@ -25,7 +25,7 @@ export async function paddleApiRequest( const isSandbox = credentials.sandbox; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: { 'content-type': 'application/json', @@ -54,7 +54,7 @@ export async function paddleApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, propertyName: string, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts index 52837e07ec..3206e20587 100644 --- a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { JsonObject, IDataObject, @@ -7,6 +5,8 @@ import type { ILoadOptionsFunctions, IHookFunctions, IWebhookFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -14,7 +14,7 @@ import { snakeCase } from 'change-case'; export async function pagerDutyApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -24,7 +24,7 @@ export async function pagerDutyApiRequest( ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Accept: 'application/vnd.pagerduty+json;version=2', }, @@ -65,7 +65,7 @@ export async function pagerDutyApiRequest( export async function pagerDutyApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts index 8c34194c5b..60f597cbe8 100644 --- a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { JsonObject, IDataObject, @@ -7,6 +5,8 @@ import type { IHookFunctions, ILoadOptionsFunctions, IWebhookFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { BINARY_ENCODING, NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -29,7 +29,7 @@ async function getAccessToken( {}, { Authorization: `Basic ${data}`, 'Content-Type': 'application/x-www-form-urlencoded' }, ); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: headerWithAuthentication, method: 'POST', form: { @@ -48,7 +48,7 @@ async function getAccessToken( export async function payPalApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, query?: IDataObject, @@ -93,7 +93,7 @@ export async function payPalApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, query?: IDataObject, diff --git a/packages/nodes-base/nodes/PayPal/PayPal.node.ts b/packages/nodes-base/nodes/PayPal/PayPal.node.ts index cb4ea65f0c..6ed04330bf 100644 --- a/packages/nodes-base/nodes/PayPal/PayPal.node.ts +++ b/packages/nodes-base/nodes/PayPal/PayPal.node.ts @@ -1,4 +1,3 @@ -import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ICredentialsDecrypted, @@ -8,6 +7,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; import { @@ -101,7 +101,7 @@ export class PayPal implements INodeType { const base64Key = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Basic ${base64Key}`, }, diff --git a/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts b/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts index 861644f312..35abf9dde4 100644 --- a/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts @@ -1,23 +1,23 @@ -import type { OptionsWithUri } from 'request'; - import type { JsonObject, IDataObject, IExecuteFunctions, ILoadOptionsFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function phantombusterApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, qs: IDataObject = {}, _option = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, body, diff --git a/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts b/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts index 77953f45e4..2e739fb536 100644 --- a/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { JsonObject, IDataObject, IExecuteFunctions, ILoadOptionsFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function philipsHueApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -18,7 +18,7 @@ export async function philipsHueApiRequest( uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts b/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts index 86bfc264ba..0d8719f4cb 100644 --- a/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts @@ -5,11 +5,11 @@ import type { IHookFunctions, ILoadOptionsFunctions, INodePropertyOptions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - export interface ICustomInterface { name: string; key: string; @@ -30,7 +30,7 @@ export interface ICustomProperties { */ export async function pipedriveApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query: IDataObject = {}, @@ -39,7 +39,7 @@ export async function pipedriveApiRequest( ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Accept: 'application/json', }, @@ -102,7 +102,7 @@ export async function pipedriveApiRequest( */ export async function pipedriveApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index a3ed0da589..25da344d36 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -1,6 +1,7 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, @@ -4084,7 +4085,7 @@ export class Pipedrive implements INodeType { let downloadFile: boolean; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; let returnAll = false; diff --git a/packages/nodes-base/nodes/Plivo/GenericFunctions.ts b/packages/nodes-base/nodes/Plivo/GenericFunctions.ts index f308f6be47..6ac63db30f 100644 --- a/packages/nodes-base/nodes/Plivo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Plivo/GenericFunctions.ts @@ -1,15 +1,20 @@ -import type { IExecuteFunctions, IHookFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IHookFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Make an API request to Plivo. * */ export async function plivoApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -19,7 +24,7 @@ export async function plivoApiRequest( authToken: string; }; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'user-agent': 'plivo-n8n', }, diff --git a/packages/nodes-base/nodes/PostHog/GenericFunctions.ts b/packages/nodes-base/nodes/PostHog/GenericFunctions.ts index 0ef0201ae6..2b2e54268c 100644 --- a/packages/nodes-base/nodes/PostHog/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PostHog/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUrl } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function posthogApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -23,7 +23,7 @@ export async function posthogApiRequest( body.api_key = credentials.apiKey as string; - const options: OptionsWithUrl = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/Postmark/GenericFunctions.ts b/packages/nodes-base/nodes/Postmark/GenericFunctions.ts index fd38598233..a1ceefe6ee 100644 --- a/packages/nodes-base/nodes/Postmark/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Postmark/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, @@ -7,18 +5,20 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function postmarkApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, option: IDataObject = {}, ): Promise { - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', Accept: 'application/json', diff --git a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts index 02baa5a776..1400bdce88 100644 --- a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function profitWellApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function profitWellApiRequest( ): Promise { try { const credentials = await this.getCredentials('profitWellApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: credentials.accessToken, }, diff --git a/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts b/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts index 003e58d981..4904d06713 100644 --- a/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function pushbulletApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -18,7 +18,7 @@ export async function pushbulletApiRequest( uri?: string | undefined, option = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, @@ -41,7 +41,7 @@ export async function pushbulletApiRequest( export async function pushbulletApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts index 7b1c8c4ec3..9c96e60fb8 100644 --- a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function pushcutApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -21,7 +21,7 @@ export async function pushcutApiRequest( ): Promise { const credentials = await this.getCredentials('pushcutApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'API-Key': credentials.apiKey, }, diff --git a/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts index e9d9278de0..73d8232aa6 100644 --- a/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -12,7 +12,7 @@ import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function quickbaseApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -30,7 +30,7 @@ export async function quickbaseApiRequest( } try { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'QB-Realm-Hostname': credentials.hostname, 'User-Agent': 'n8n', @@ -77,7 +77,7 @@ export async function getFieldsObject(this: IHookFunctions | ILoadOptionsFunctio export async function quickbaseApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts index 85a73ca4f3..3f28e2d56a 100644 --- a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts @@ -2,9 +2,11 @@ import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -14,7 +16,6 @@ import { capitalCase } from 'change-case'; import omit from 'lodash/omit'; import pickBy from 'lodash/pickBy'; -import type { OptionsWithUri } from 'request'; import type { CustomField, GeneralAddress, Ref } from './descriptions/Shared.interface'; import type { DateFieldsUi, Option, QuickBooksOAuth2Credentials, TransactionReport } from './types'; @@ -24,7 +25,7 @@ import type { DateFieldsUi, Option, QuickBooksOAuth2Credentials, TransactionRepo */ export async function quickBooksApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, body: IDataObject, @@ -46,7 +47,7 @@ export async function quickBooksApiRequest( 'quickBooksOAuth2Api', )) as QuickBooksOAuth2Credentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'user-agent': 'n8n', }, @@ -93,7 +94,7 @@ export async function quickBooksApiRequest( async function getCount( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, ): Promise { @@ -107,7 +108,7 @@ async function getCount( */ export async function quickBooksApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, body: IDataObject, diff --git a/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts b/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts index cde8a82e90..ac2e2d87bc 100644 --- a/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts @@ -4,23 +4,23 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Make an authenticated API request to Raindrop. */ export async function raindropApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, body: IDataObject, option: IDataObject = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'user-agent': 'n8n', 'Content-Type': 'application/json', diff --git a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts index 0008785eba..e18982f9b9 100644 --- a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts @@ -1,14 +1,19 @@ -import type { IExecuteFunctions, IHookFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IHookFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Make an authenticated or unauthenticated API request to Reddit. */ export async function redditApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, ): Promise { @@ -18,7 +23,7 @@ export async function redditApiRequest( qs.api_type = 'json'; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'user-agent': 'n8n', }, @@ -54,7 +59,7 @@ export async function redditApiRequest( */ export async function redditApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, qs: IDataObject, ): Promise { diff --git a/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts b/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts index 77c0ce955d..4a230c48d4 100644 --- a/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts @@ -1,19 +1,23 @@ -import type { OptionsWithUri } from 'request'; - -import type { IDataObject, IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { + IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, +} from 'n8n-workflow'; export async function rocketchatApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, resource: string, - method: string, + method: IHttpRequestMethods, operation: string, body: any = {}, - headers?: object, + headers?: IDataObject, ): Promise { const credentials = await this.getCredentials('rocketchatApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers, method, body, diff --git a/packages/nodes-base/nodes/Rundeck/RundeckApi.ts b/packages/nodes-base/nodes/Rundeck/RundeckApi.ts index bab3fc5f11..4053912a55 100644 --- a/packages/nodes-base/nodes/Rundeck/RundeckApi.ts +++ b/packages/nodes-base/nodes/Rundeck/RundeckApi.ts @@ -1,5 +1,10 @@ -import type { OptionsWithUri } from 'request'; -import type { IDataObject, IExecuteFunctions, JsonObject } from 'n8n-workflow'; +import type { + IDataObject, + IExecuteFunctions, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export interface RundeckCredentials { @@ -16,10 +21,15 @@ export class RundeckApi { this.executeFunctions = executeFunctions; } - protected async request(method: string, endpoint: string, body: IDataObject, query: object) { + protected async request( + method: IHttpRequestMethods, + endpoint: string, + body: IDataObject, + query: IDataObject, + ) { const credentialType = 'rundeckApi'; - const options: OptionsWithUri = { + const options: IRequestOptions = { rejectUnauthorized: false, method, qs: query, diff --git a/packages/nodes-base/nodes/S3/GenericFunctions.ts b/packages/nodes-base/nodes/S3/GenericFunctions.ts index e79ef74348..8506edbe82 100644 --- a/packages/nodes-base/nodes/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/S3/GenericFunctions.ts @@ -4,15 +4,15 @@ import { sign } from 'aws4'; import get from 'lodash/get'; -import type { OptionsWithUri } from 'request'; - import { parseString } from 'xml2js'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -27,7 +27,7 @@ function queryToString(params: IDataObject) { export async function s3ApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, bucket: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer, query: IDataObject = {}, @@ -77,7 +77,7 @@ export async function s3ApiRequest( sign(signOpts, securityHeaders); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: signOpts.headers, method, qs: query, @@ -98,7 +98,7 @@ export async function s3ApiRequest( export async function s3ApiRequestREST( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, bucket: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, @@ -127,7 +127,7 @@ export async function s3ApiRequestREST( export async function s3ApiRequestSOAP( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, bucket: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string | Buffer, query: IDataObject = {}, @@ -164,7 +164,7 @@ export async function s3ApiRequestSOAPAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, service: string, - method: string, + method: IHttpRequestMethods, path: string, body?: string, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts index 8f7da0f772..49292d869c 100644 --- a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, INodePropertyOptions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -15,14 +15,14 @@ import jwt from 'jsonwebtoken'; function getOptions( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any, qs: IDataObject, instanceUrl: string, -): OptionsWithUri { - const options: OptionsWithUri = { +): IRequestOptions { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -66,7 +66,7 @@ async function getAccessToken( }, ); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, @@ -84,7 +84,7 @@ async function getAccessToken( export async function salesforceApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -144,7 +144,7 @@ export async function salesforceApiRequest( export async function salesforceApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts index a05844e7fd..4db839ba1d 100644 --- a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts +++ b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts @@ -7,6 +7,7 @@ import type { INodeType, INodeTypeDescription, JsonObject, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -1169,7 +1170,7 @@ export class Salesforce implements INodeType { } } let endpoint = '/sobjects/lead'; - let method = 'POST'; + let method: IHttpRequestMethods = 'POST'; if (operation === 'upsert') { method = 'PATCH'; const externalId = this.getNodeParameter('externalId', 0) as string; @@ -1497,7 +1498,7 @@ export class Salesforce implements INodeType { } } let endpoint = '/sobjects/contact'; - let method = 'POST'; + let method: IHttpRequestMethods = 'POST'; if (operation === 'upsert') { method = 'PATCH'; const externalId = this.getNodeParameter('externalId', 0) as string; @@ -1749,7 +1750,7 @@ export class Salesforce implements INodeType { body.RecordTypeId = additionalFields.recordTypeId as string; } let endpoint = `/sobjects/${customObject}`; - let method = 'POST'; + let method: IHttpRequestMethods = 'POST'; if (operation === 'upsert') { method = 'PATCH'; const externalId = this.getNodeParameter('externalId', 0) as string; @@ -1944,7 +1945,7 @@ export class Salesforce implements INodeType { } } let endpoint = '/sobjects/opportunity'; - let method = 'POST'; + let method: IHttpRequestMethods = 'POST'; if (operation === 'upsert') { method = 'PATCH'; const externalId = this.getNodeParameter('externalId', 0) as string; @@ -2193,7 +2194,7 @@ export class Salesforce implements INodeType { } } let endpoint = '/sobjects/account'; - let method = 'POST'; + let method: IHttpRequestMethods = 'POST'; if (operation === 'upsert') { method = 'PATCH'; const externalId = this.getNodeParameter('externalId', 0) as string; diff --git a/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts b/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts index ec87988a00..287da42e7e 100644 --- a/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, @@ -7,12 +5,14 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function salesmateApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -22,7 +22,7 @@ export async function salesmateApiRequest( ): Promise { const credentials = await this.getCredentials('salesmateApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { sessionToken: credentials.sessionToken, 'x-linkname': credentials.url, @@ -47,7 +47,7 @@ export async function salesmateApiRequest( export async function salesmateApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts index d08880507b..fe43181321 100644 --- a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, ILoadOptionsFunctions, IPollFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -49,7 +49,7 @@ export async function getBaseAccessToken( return; } - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Token ${ctx?.credentials?.token}`, }, @@ -76,7 +76,7 @@ function endpointCtxExpr(ctx: ICtx, endpoint: string): string { export async function seaTableApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, ctx: ICtx, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, @@ -90,7 +90,7 @@ export async function seaTableApiRequest( await getBaseAccessToken.call(this, ctx); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Token ${ctx?.base?.access_token}`, }, @@ -120,7 +120,7 @@ export async function setableApiRequestAllItems( this: IExecuteFunctions | IPollFunctions, ctx: ICtx, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts b/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts index c3ed713a8d..fbfff300d6 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function scorecardApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -23,7 +23,7 @@ export async function scorecardApiRequest( const headerWithAuthentication = { Authorization: `Token ${credentials.apiKey}` }; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: headerWithAuthentication, method, qs: query, diff --git a/packages/nodes-base/nodes/Segment/GenericFunctions.ts b/packages/nodes-base/nodes/Segment/GenericFunctions.ts index 8df8cc85bf..fa75e24a54 100644 --- a/packages/nodes-base/nodes/Segment/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Segment/GenericFunctions.ts @@ -1,22 +1,23 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, } from 'n8n-workflow'; export async function segmentApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, _option: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, diff --git a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts index ee7339ede3..08ba895782 100644 --- a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, } from 'n8n-workflow'; export async function sendGridApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, endpoint: string, - method: string, + method: IHttpRequestMethods, body: any = {}, qs: IDataObject = {}, @@ -18,7 +18,7 @@ export async function sendGridApiRequest( ): Promise { const host = 'api.sendgrid.com/v3'; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, qs, body, @@ -40,7 +40,7 @@ export async function sendGridApiRequest( export async function sendGridApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, endpoint: string, - method: string, + method: IHttpRequestMethods, propertyName: string, body: any = {}, diff --git a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts index c343239128..fd889ea057 100644 --- a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts +++ b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts @@ -1,6 +1,7 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, @@ -146,7 +147,7 @@ export class SendGrid implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); const filters = this.getNodeParameter('filters', i); let endpoint = '/marketing/contacts'; - let method = 'GET'; + let method: IHttpRequestMethods = 'GET'; const body: IDataObject = {}; if (filters.query && filters.query !== '') { endpoint = '/marketing/contacts/search'; @@ -186,7 +187,7 @@ export class SendGrid implements INodeType { if (operation === 'get') { const by = this.getNodeParameter('by', 0) as string; let endpoint; - let method; + let method: IHttpRequestMethods; const body: IDataObject = {}; for (let i = 0; i < length; i++) { try { diff --git a/packages/nodes-base/nodes/Sendy/GenericFunctions.ts b/packages/nodes-base/nodes/Sendy/GenericFunctions.ts index c36e00fb7a..e55ffca5a5 100644 --- a/packages/nodes-base/nodes/Sendy/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Sendy/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { - IExecuteFunctions, - ILoadOptionsFunctions, IDataObject, + IExecuteFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function sendyApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: any = {}, @@ -23,7 +23,7 @@ export async function sendyApiRequest( body.boolean = true; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, diff --git a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts index 435e854146..9c70f97994 100644 --- a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -12,7 +12,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function sentryIoApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -24,14 +24,14 @@ export async function sentryIoApiRequest( const version = this.getNodeParameter('sentryVersion', 0); - const options: OptionsWithUri = { + const options = { headers: {}, method, qs, body, uri: uri || `https://sentry.io${resource}`, json: true, - }; + } satisfies IRequestOptions; if (!Object.keys(body as IDataObject).length) { delete options.body; } @@ -95,7 +95,7 @@ function hasMore(link: string) { export async function sentryApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts b/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts index 71d9e99773..ded0e97c32 100644 --- a/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, INodePropertyOptions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function serviceNowApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -30,14 +30,14 @@ export async function serviceNowApiRequest( credentials = await this.getCredentials('serviceNowOAuth2Api'); } - const options: OptionsWithUri = { + const options = { headers, method, qs, body, uri: uri || `https://${credentials.subdomain}.service-now.com/api${resource}`, json: true, - }; + } satisfies IRequestOptions; if (!Object.keys(body as IDataObject).length) { delete options.body; } @@ -61,7 +61,7 @@ export async function serviceNowApiRequest( export async function serviceNowRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts index 54872b2fe4..d2d1852ad6 100644 --- a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts @@ -1,18 +1,18 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, IOAuth2Options, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { snakeCase } from 'change-case'; export async function shopifyApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -35,7 +35,7 @@ export async function shopifyApiRequest( credentials = await this.getCredentials('shopifyOAuth2Api'); } - const options: OptionsWithUri = { + const options: IRequestOptions = { method, qs: query, uri: uri || `https://${credentials.shopSubdomain}.myshopify.com/admin/api/2019-10${resource}`, @@ -86,7 +86,7 @@ export async function shopifyApiRequest( export async function shopifyApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Signl4/GenericFunctions.ts b/packages/nodes-base/nodes/Signl4/GenericFunctions.ts index 198ace3caf..8ad84c272c 100644 --- a/packages/nodes-base/nodes/Signl4/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Signl4/GenericFunctions.ts @@ -1,8 +1,12 @@ -import type { IExecuteFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IDataObject, + JsonObject, + IRequestOptions, + IHttpRequestMethods, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Make an API request to SIGNL4 * @@ -12,7 +16,7 @@ import type { OptionsWithUri } from 'request'; export async function SIGNL4ApiRequest( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, body: string, query: IDataObject = {}, option: IDataObject = {}, @@ -21,7 +25,7 @@ export async function SIGNL4ApiRequest( const teamSecret = credentials?.teamSecret as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: '*/*', }, diff --git a/packages/nodes-base/nodes/Slack/V1/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/V1/GenericFunctions.ts index a52f6e85b5..c31607dc0c 100644 --- a/packages/nodes-base/nodes/Slack/V1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/V1/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, IOAuth2Options, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -13,15 +13,15 @@ import get from 'lodash/get'; export async function slackApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: object = {}, - query: object = {}, + query: IDataObject = {}, headers: IDataObject | undefined = undefined, option: IDataObject = {}, ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { method, headers: headers || { 'Content-Type': 'application/json; charset=utf-8', @@ -85,7 +85,7 @@ export async function slackApiRequest( export async function slackApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts index dc303cc25d..7df2ff5d11 100644 --- a/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts @@ -1,9 +1,10 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, ILoadOptionsFunctions, IOAuth2Options, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeOperationError, jsonParse } from 'n8n-workflow'; @@ -12,16 +13,16 @@ import get from 'lodash/get'; export async function slackApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: object = {}, - query: object = {}, + query: IDataObject = {}, headers: {} | undefined = undefined, option: {} = {}, // tslint:disable-next-line:no-any ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { method, headers: headers ?? { 'Content-Type': 'application/json; charset=utf-8', @@ -92,7 +93,7 @@ export async function slackApiRequest( export async function slackApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, // tslint:disable-next-line:no-any body: any = {}, diff --git a/packages/nodes-base/nodes/Sms77/GenericFunctions.ts b/packages/nodes-base/nodes/Sms77/GenericFunctions.ts index 2a67b32f13..90f92939c1 100644 --- a/packages/nodes-base/nodes/Sms77/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Sms77/GenericFunctions.ts @@ -1,8 +1,13 @@ -import type { IDataObject, IExecuteFunctions, IHookFunctions, JsonObject } from 'n8n-workflow'; +import type { + IDataObject, + IExecuteFunctions, + IHookFunctions, + IHttpRequestMethods, + IRequestOptions, + JsonObject, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - /** * Make an API request to seven * @@ -11,12 +16,12 @@ import type { OptionsWithUri } from 'request'; */ export async function sms77ApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, qs: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { SentWith: 'n8n', }, diff --git a/packages/nodes-base/nodes/Splunk/GenericFunctions.ts b/packages/nodes-base/nodes/Splunk/GenericFunctions.ts index b661f9e573..731bd1808f 100644 --- a/packages/nodes-base/nodes/Splunk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Splunk/GenericFunctions.ts @@ -3,11 +3,11 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import { parseString } from 'xml2js'; import type { @@ -108,7 +108,7 @@ export function toUnixEpoch(timestamp: string) { export async function splunkApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -117,7 +117,7 @@ export async function splunkApiRequest( 'splunkApi', )) as SplunkCredentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/x-www-form-urlencoded', diff --git a/packages/nodes-base/nodes/Splunk/Splunk.node.ts b/packages/nodes-base/nodes/Splunk/Splunk.node.ts index 371ab8abb2..c25d70f83f 100644 --- a/packages/nodes-base/nodes/Splunk/Splunk.node.ts +++ b/packages/nodes-base/nodes/Splunk/Splunk.node.ts @@ -8,9 +8,9 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; import { formatFeed, formatResults, @@ -124,7 +124,7 @@ export class Splunk implements INodeType { const endpoint = '/services/alerts/fired_alerts'; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/x-www-form-urlencoded', diff --git a/packages/nodes-base/nodes/Spontit/GenericFunctions.ts b/packages/nodes-base/nodes/Spontit/GenericFunctions.ts index 38e75aa3d1..d4ca5e48fd 100644 --- a/packages/nodes-base/nodes/Spontit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Spontit/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -12,7 +12,7 @@ import { NodeApiError } from 'n8n-workflow'; export async function spontitApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -21,7 +21,7 @@ export async function spontitApiRequest( const credentials = await this.getCredentials('spontitApi'); try { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'X-Authorization': credentials.apiKey as string, 'X-UserId': credentials.username as string, diff --git a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts index f78b01c5fa..6b61655ee3 100644 --- a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts @@ -1,6 +1,11 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IHookFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IDataObject, + IExecuteFunctions, + IHookFunctions, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import get from 'lodash/get'; @@ -11,13 +16,13 @@ import get from 'lodash/get'; */ export async function spotifyApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, - query?: object, + query?: IDataObject, uri?: string, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, headers: { 'User-Agent': 'n8n', @@ -42,10 +47,10 @@ export async function spotifyApiRequest( export async function spotifyApiRequestAllItems( this: IHookFunctions | IExecuteFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, - query?: object, + query?: IDataObject, ): Promise { const returnData: IDataObject[] = []; diff --git a/packages/nodes-base/nodes/Spotify/Spotify.node.ts b/packages/nodes-base/nodes/Spotify/Spotify.node.ts index fe949c032f..329d998da1 100644 --- a/packages/nodes-base/nodes/Spotify/Spotify.node.ts +++ b/packages/nodes-base/nodes/Spotify/Spotify.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { spotifyApiRequest, spotifyApiRequestAllItems } from './GenericFunctions'; @@ -789,7 +790,7 @@ export class Spotify implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; let returnAll: boolean; let propertyName = ''; diff --git a/packages/nodes-base/nodes/Stackby/GenericFunction.ts b/packages/nodes-base/nodes/Stackby/GenericFunction.ts index d5368105d1..f5b6f8f4a3 100644 --- a/packages/nodes-base/nodes/Stackby/GenericFunction.ts +++ b/packages/nodes-base/nodes/Stackby/GenericFunction.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, IPollFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -16,7 +16,7 @@ import { NodeApiError } from 'n8n-workflow'; */ export async function apiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, @@ -25,7 +25,7 @@ export async function apiRequest( ): Promise { const credentials = await this.getCredentials('stackbyApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'api-key': credentials.apiKey, 'Content-Type': 'application/json', @@ -60,7 +60,7 @@ export async function apiRequest( */ export async function apiRequestAllItems( this: IHookFunctions | IExecuteFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts b/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts index 4c622ff68c..00401d9772 100644 --- a/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function storyblokApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -19,7 +19,7 @@ export async function storyblokApiRequest( ) { const authenticationMethod = this.getNodeParameter('source', 0) as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -32,7 +32,7 @@ export async function storyblokApiRequest( options = Object.assign({}, options, option); - if (Object.keys(options.body as IDataObject).length === 0) { + if (Object.keys(options.body).length === 0) { delete options.body; } @@ -41,7 +41,7 @@ export async function storyblokApiRequest( options.uri = `https://api.storyblok.com${resource}`; - Object.assign(options.qs, { token: credentials.apiKey }); + Object.assign(options.qs ?? {}, { token: credentials.apiKey }); } else { const credentials = await this.getCredentials('storyblokManagementApi'); @@ -62,7 +62,7 @@ export async function storyblokApiRequest( export async function storyblokApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts index 9f786105b8..b687766037 100644 --- a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -20,7 +20,7 @@ export const removeTrailingSlash = (url: string) => { export async function strapiApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -39,7 +39,7 @@ export async function strapiApiRequest( const url = removeTrailingSlash(credentials.url as string); try { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, body, @@ -47,7 +47,7 @@ export async function strapiApiRequest( uri: uri || credentials.apiVersion === 'v4' ? `${url}/api${resource}` : `${url}${resource}`, json: true, qsStringifyOptions: { - arrayFormat: 'indice', + arrayFormat: 'indices', }, }; if (Object.keys(headers).length !== 0) { @@ -74,7 +74,7 @@ export async function getToken( const url = removeTrailingSlash(credentials.url as string); - let options = {} as OptionsWithUri; + let options = {} as IRequestOptions; options = { headers: { 'content-type': 'application/json', @@ -92,7 +92,7 @@ export async function getToken( export async function strapiApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Strapi/Strapi.node.ts b/packages/nodes-base/nodes/Strapi/Strapi.node.ts index ff45e2bd61..4633e2819a 100644 --- a/packages/nodes-base/nodes/Strapi/Strapi.node.ts +++ b/packages/nodes-base/nodes/Strapi/Strapi.node.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ICredentialsDecrypted, @@ -9,6 +7,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -99,7 +98,7 @@ export class Strapi implements INodeType { credential: ICredentialsDecrypted, ): Promise { const credentials = credential.data as IDataObject; - let options = {} as OptionsWithUri; + let options: IRequestOptions = {}; const url = removeTrailingSlash(credentials.url as string); diff --git a/packages/nodes-base/nodes/Strava/GenericFunctions.ts b/packages/nodes-base/nodes/Strava/GenericFunctions.ts index e50c15054e..d5488b7e0e 100644 --- a/packages/nodes-base/nodes/Strava/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strava/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -12,14 +12,14 @@ import { NodeApiError } from 'n8n-workflow'; export async function stravaApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, form: body, qs, @@ -57,7 +57,7 @@ export async function stravaApiRequest( export async function stravaApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Stripe/helpers.ts b/packages/nodes-base/nodes/Stripe/helpers.ts index 6057f6f210..f5d300b8c8 100644 --- a/packages/nodes-base/nodes/Stripe/helpers.ts +++ b/packages/nodes-base/nodes/Stripe/helpers.ts @@ -7,6 +7,8 @@ import type { IDataObject, ILoadOptionsFunctions, INodePropertyOptions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; /** @@ -15,10 +17,10 @@ import type { */ export async function stripeApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, - body: object, - query?: object, + body: IDataObject, + query?: IDataObject, ) { const options = { method, @@ -26,7 +28,7 @@ export async function stripeApiRequest( qs: query, uri: `https://api.stripe.com/v1${endpoint}`, json: true, - }; + } satisfies IRequestOptions; if (options.qs && Object.keys(options.qs).length === 0) { delete options.qs; diff --git a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts index 3716dca3ea..4366409e2a 100644 --- a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, @@ -11,12 +9,14 @@ import type { INodeProperties, IPairedItemData, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function supabaseApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject | IDataObject[] = {}, qs: IDataObject = {}, @@ -28,7 +28,7 @@ export async function supabaseApiRequest( serviceRole: string; }; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Prefer: 'return=representation', }, @@ -302,7 +302,7 @@ export async function validateCredentials( serviceRole: string; }; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { apikey: serviceRole, Authorization: 'Bearer ' + serviceRole, diff --git a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts index da7da90736..ec53b79698 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, @@ -7,12 +5,14 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function surveyMonkeyApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, @@ -24,7 +24,7 @@ export async function surveyMonkeyApiRequest( const endpoint = 'https://api.surveymonkey.com/v3'; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -61,7 +61,7 @@ export async function surveyMonkeyApiRequest( export async function surveyMonkeyRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Taiga/GenericFunctions.ts b/packages/nodes-base/nodes/Taiga/GenericFunctions.ts index 71395a5b2e..d01e36cdd4 100644 --- a/packages/nodes-base/nodes/Taiga/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Taiga/GenericFunctions.ts @@ -1,5 +1,4 @@ import { createHash } from 'crypto'; -import type { OptionsWithUri } from 'request'; import type { ICredentialDataDecryptedObject, @@ -9,6 +8,8 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -21,7 +22,7 @@ export async function getAuthorization( } const { password, username } = credentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json' }, method: 'POST', body: { @@ -44,7 +45,7 @@ export async function getAuthorization( export async function taigaApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body = {}, query = {}, @@ -55,7 +56,7 @@ export async function taigaApiRequest( const authToken = await getAuthorization.call(this, credentials); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -85,7 +86,7 @@ export async function taigaApiRequest( export async function taigaApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, @@ -121,7 +122,7 @@ export function getAutomaticSecret(credentials: ICredentialDataDecryptedObject) export async function handleListing( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, qs: IDataObject, diff --git a/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts b/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts index 5bcfa3763a..5c8a836926 100644 --- a/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function tapfiliateApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, @@ -21,7 +21,7 @@ export async function tapfiliateApiRequest( ) { const credentials = await this.getCredentials('tapfiliateApi'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Api-Key': credentials.apiKey, }, @@ -48,7 +48,7 @@ export async function tapfiliateApiRequest( export async function tapfiliateApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts index cdf12b5737..431e41e7ec 100644 --- a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, IWebhookFunctions, JsonObject, } from 'n8n-workflow'; @@ -181,7 +181,7 @@ export function addAdditionalFields( */ export async function apiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, @@ -191,7 +191,7 @@ export async function apiRequest( query = query || {}; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, uri: `https://api.telegram.org/bot${credentials.accessToken}/${endpoint}`, diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index cf721c1adc..7c2f7aebdb 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -6,6 +6,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { BINARY_ENCODING, NodeOperationError } from 'n8n-workflow'; @@ -1709,7 +1710,7 @@ export class Telegram implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; const operation = this.getNodeParameter('operation', 0); diff --git a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts index acf574c8fe..ab9a4cd445 100644 --- a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, IDataObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { ApplicationError, jsonParse } from 'n8n-workflow'; @@ -13,7 +13,7 @@ import { Eq } from './QueryFunctions'; export async function theHiveApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, query: IDataObject = {}, @@ -22,7 +22,7 @@ export async function theHiveApiRequest( ) { const credentials = await this.getCredentials('theHiveApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, qs: query, uri: uri || `${credentials.url}/api${resource}`, diff --git a/packages/nodes-base/nodes/TheHive/TheHive.node.ts b/packages/nodes-base/nodes/TheHive/TheHive.node.ts index 8bd8ce91bb..8b37019c89 100644 --- a/packages/nodes-base/nodes/TheHive/TheHive.node.ts +++ b/packages/nodes-base/nodes/TheHive/TheHive.node.ts @@ -2,6 +2,7 @@ import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, INodeParameters, @@ -543,7 +544,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -903,7 +904,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -944,7 +945,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -1042,7 +1043,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -1250,7 +1251,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -1316,7 +1317,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -1499,7 +1500,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -1541,7 +1542,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -1623,7 +1624,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -1795,7 +1796,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; @@ -1836,7 +1837,7 @@ export class TheHive implements INodeType { let endpoint; - let method; + let method: IHttpRequestMethods; let body: IDataObject = {}; diff --git a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts index 4278cc905a..fb8cfc9bba 100644 --- a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -19,7 +19,7 @@ export function FormatDueDatetime(isoString: string): string { export async function todoistApiRequest( this: Context, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -28,7 +28,7 @@ export async function todoistApiRequest( const endpoint = 'api.todoist.com/rest/v2'; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, qs, uri: `https://${endpoint}${resource}`, @@ -54,7 +54,7 @@ export async function todoistSyncRequest( ): Promise { const authentication = this.getNodeParameter('authentication', 0, 'oAuth2'); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method: 'POST', qs, diff --git a/packages/nodes-base/nodes/Toggl/GenericFunctions.ts b/packages/nodes-base/nodes/Toggl/GenericFunctions.ts index 064cddfcd0..48b018a215 100644 --- a/packages/nodes-base/nodes/Toggl/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Toggl/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, IPollFunctions, + IRequestOptions, ITriggerFunctions, JsonObject, } from 'n8n-workflow'; @@ -18,7 +18,7 @@ export async function togglApiRequest( | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, query?: IDataObject, @@ -34,7 +34,7 @@ export async function togglApiRequest( }, ); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: headerWithAuthentication, method, qs: query, diff --git a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts index 14d1d82a6c..b089998eb8 100644 --- a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -13,7 +13,7 @@ import get from 'lodash/get'; export async function travisciApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject | string = {}, qs: IDataObject = {}, @@ -21,7 +21,7 @@ export async function travisciApiRequest( option: IDataObject = {}, ) { const credentials = await this.getCredentials('travisCiApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'Travis-API-Version': '3', Accept: 'application/json', @@ -52,7 +52,7 @@ export async function travisciApiRequest( export async function travisciApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Trello/GenericFunctions.ts b/packages/nodes-base/nodes/Trello/GenericFunctions.ts index d7873cc491..18fcbee1a7 100644 --- a/packages/nodes-base/nodes/Trello/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Trello/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, } from 'n8n-workflow'; /** @@ -13,14 +13,14 @@ import type { */ export async function apiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, query?: IDataObject, ): Promise { query = query || {}; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs: query, @@ -33,7 +33,7 @@ export async function apiRequest( export async function apiRequestAllItems( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Trello/Trello.node.ts b/packages/nodes-base/nodes/Trello/Trello.node.ts index ace3604860..22cbba53d6 100644 --- a/packages/nodes-base/nodes/Trello/Trello.node.ts +++ b/packages/nodes-base/nodes/Trello/Trello.node.ts @@ -6,6 +6,7 @@ import type { INodeListSearchResult, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -202,7 +203,7 @@ export class Trello implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; let returnAll = false; let responseData; diff --git a/packages/nodes-base/nodes/Twake/GenericFunctions.ts b/packages/nodes-base/nodes/Twake/GenericFunctions.ts index 30375bf813..fb3d2482ed 100644 --- a/packages/nodes-base/nodes/Twake/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twake/GenericFunctions.ts @@ -1,5 +1,11 @@ -import type { OptionsWithUri } from 'request'; -import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { + IDataObject, + IExecuteFunctions, + IHookFunctions, + IHttpRequestMethods, + ILoadOptionsFunctions, + IRequestOptions, +} from 'n8n-workflow'; /** * Make an API request to Twake @@ -7,13 +13,13 @@ import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n */ export async function twakeApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: object, - query?: object, + query?: IDataObject, uri?: string, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, body, diff --git a/packages/nodes-base/nodes/Twilio/GenericFunctions.ts b/packages/nodes-base/nodes/Twilio/GenericFunctions.ts index 118495ce9f..6c81b0b3be 100644 --- a/packages/nodes-base/nodes/Twilio/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twilio/GenericFunctions.ts @@ -1,6 +1,10 @@ -import type { IExecuteFunctions, IHookFunctions, IDataObject } from 'n8n-workflow'; - -import type { OptionsWithUri } from 'request'; +import type { + IExecuteFunctions, + IHookFunctions, + IDataObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; /** * Make an API request to Twilio @@ -8,7 +12,7 @@ import type { OptionsWithUri } from 'request'; */ export async function twilioApiRequest( this: IHookFunctions | IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, @@ -25,7 +29,7 @@ export async function twilioApiRequest( query = {}; } - const options: OptionsWithUri = { + const options: IRequestOptions = { method, form: body, qs: query, diff --git a/packages/nodes-base/nodes/Twilio/Twilio.node.ts b/packages/nodes-base/nodes/Twilio/Twilio.node.ts index 55de035ead..a07e525f2a 100644 --- a/packages/nodes-base/nodes/Twilio/Twilio.node.ts +++ b/packages/nodes-base/nodes/Twilio/Twilio.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -212,7 +213,7 @@ export class Twilio implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; for (let i = 0; i < items.length; i++) { diff --git a/packages/nodes-base/nodes/Twist/GenericFunctions.ts b/packages/nodes-base/nodes/Twist/GenericFunctions.ts index 95a8564d9f..64a5f803b2 100644 --- a/packages/nodes-base/nodes/Twist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twist/GenericFunctions.ts @@ -1,22 +1,22 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function twistApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, option: IDataObject = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, diff --git a/packages/nodes-base/nodes/Twitter/V1/GenericFunctions.ts b/packages/nodes-base/nodes/Twitter/V1/GenericFunctions.ts index 03b0efa30b..40a19fea00 100644 --- a/packages/nodes-base/nodes/Twitter/V1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twitter/V1/GenericFunctions.ts @@ -1,24 +1,24 @@ -import type { OptionsWithUrl } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError, sleep } from 'n8n-workflow'; export async function twitterApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}, ) { - let options: OptionsWithUrl = { + let options: IRequestOptions = { method, body, qs, @@ -44,7 +44,7 @@ export async function twitterApiRequest( export async function twitterApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Twitter/V2/GenericFunctions.ts b/packages/nodes-base/nodes/Twitter/V2/GenericFunctions.ts index 353de66b06..33f238add0 100644 --- a/packages/nodes-base/nodes/Twitter/V2/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twitter/V2/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUrl } from 'request'; - import type { IDataObject, IExecuteFunctions, @@ -7,12 +5,14 @@ import type { ILoadOptionsFunctions, INodeParameterResourceLocator, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { ApplicationError, NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function twitterApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -20,7 +20,7 @@ export async function twitterApiRequest( uri?: string, option: IDataObject = {}, ) { - let options: OptionsWithUrl = { + let options: IRequestOptions = { method, body, qs, @@ -59,7 +59,7 @@ export async function twitterApiRequest( export async function twitterApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts index 7248439ec0..f7262b7a83 100644 --- a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts @@ -5,11 +5,11 @@ import type { IDataObject, INodePropertyOptions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - // Interface in Typeform export interface ITypeformDefinition { fields: ITypeformDefinitionField[]; @@ -39,14 +39,14 @@ export interface ITypeformAnswerField { */ export async function apiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, query?: IDataObject, ): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: {}, method, body, @@ -76,7 +76,7 @@ export async function apiRequest( */ export async function apiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject, query?: IDataObject, diff --git a/packages/nodes-base/nodes/UProc/GenericFunctions.ts b/packages/nodes-base/nodes/UProc/GenericFunctions.ts index e66c53a64a..b5cb760b9d 100644 --- a/packages/nodes-base/nodes/UProc/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UProc/GenericFunctions.ts @@ -11,14 +11,14 @@ import { NodeApiError } from 'n8n-workflow'; export async function uprocApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, body: any = {}, qs: IDataObject = {}, uri?: string, _option: IDataObject = {}, ): Promise { const options: IHttpRequestOptions = { - method: method as IHttpRequestMethods, + method, qs, body, url: 'https://api.uproc.io/api/v2/process', diff --git a/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts b/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts index d566ccd94c..23c0b1d8c6 100644 --- a/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts @@ -1,12 +1,12 @@ import { createHmac } from 'crypto'; -import type { OptionsWithUrl } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -14,7 +14,7 @@ import qs from 'qs'; export async function unleashedApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, body: IDataObject = {}, query: IDataObject = {}, @@ -23,7 +23,7 @@ export async function unleashedApiRequest( ) { const paginatedPath = pageNumber ? `/${path}/${pageNumber}` : `/${path}`; - const options: OptionsWithUrl = { + const options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -60,7 +60,7 @@ export async function unleashedApiRequest( export async function unleashedApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Uplead/GenericFunctions.ts b/packages/nodes-base/nodes/Uplead/GenericFunctions.ts index 75cd656355..1c73b029fd 100644 --- a/packages/nodes-base/nodes/Uplead/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Uplead/GenericFunctions.ts @@ -1,16 +1,17 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function upleadApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -19,7 +20,7 @@ export async function upleadApiRequest( option: IDataObject = {}, ): Promise { const credentials = await this.getCredentials('upleadApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: credentials.apiKey }, method, qs, diff --git a/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts b/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts index 4643c82dcf..308c1c4a07 100644 --- a/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts @@ -1,11 +1,15 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IDataObject, JsonObject } from 'n8n-workflow'; +import type { + IExecuteFunctions, + IDataObject, + JsonObject, + IHttpRequestMethods, + IRequestOptions, +} from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function uptimeRobotApiRequest( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -14,7 +18,7 @@ export async function uptimeRobotApiRequest( ) { const credentials = await this.getCredentials('uptimeRobotApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, qs, form: { diff --git a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts index 5b42d87460..558d54496e 100644 --- a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts @@ -1,6 +1,4 @@ -import type { OptionsWithUri } from 'request'; - -import type { IExecuteFunctions, IDataObject } from 'n8n-workflow'; +import type { IExecuteFunctions, IDataObject, IRequestOptions } from 'n8n-workflow'; export async function urlScanIoApiRequest( this: IExecuteFunctions, @@ -9,7 +7,7 @@ export async function urlScanIoApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, diff --git a/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts b/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts index ecb654ceb5..6887a0cf78 100644 --- a/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts @@ -1,18 +1,18 @@ -import type { OptionsWithUri } from 'request'; - import { ApplicationError } from 'n8n-workflow'; import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, IPollFunctions, + IRequestOptions, } from 'n8n-workflow'; import get from 'lodash/get'; export async function venafiApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -21,7 +21,7 @@ export async function venafiApiRequest( ): Promise { const credentials = (await this.getCredentials('venafiTlsProtectDatacenterApi')) as IDataObject; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -63,7 +63,7 @@ export async function venafiApiRequest( export async function venafiApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts b/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts index 2f7ff69d99..de82bd7585 100644 --- a/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, IHookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -15,7 +15,7 @@ import * as nacl_factory from 'js-nacl'; export async function venafiApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body = {}, qs: IDataObject = {}, @@ -27,7 +27,7 @@ export async function venafiApiRequest( const region = credentials.region ?? 'cloud'; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Accept: 'application/json', 'content-type': 'application/json', @@ -70,7 +70,7 @@ export async function venafiApiRequest( export async function venafiApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Vero/GenericFunctions.ts b/packages/nodes-base/nodes/Vero/GenericFunctions.ts index 822ff0409f..51df117aa1 100644 --- a/packages/nodes-base/nodes/Vero/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Vero/GenericFunctions.ts @@ -1,15 +1,16 @@ -import type { OptionsWithUri } from 'request'; import type { IDataObject, IExecuteFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function veroApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -19,7 +20,7 @@ export async function veroApiRequest( ): Promise { const credentials = await this.getCredentials('veroApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, qs, body, diff --git a/packages/nodes-base/nodes/Vonage/GenericFunctions.ts b/packages/nodes-base/nodes/Vonage/GenericFunctions.ts index 843bccc9ce..41618f755c 100644 --- a/packages/nodes-base/nodes/Vonage/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Vonage/GenericFunctions.ts @@ -1,18 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function vonageApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, path: string, - body: any = {}, qs: IDataObject = {}, _option = {}, @@ -23,7 +22,7 @@ export async function vonageApiRequest( body.api_secret = credentials.apiSecret as string; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, form: body, qs, diff --git a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts index 459b6d7d75..4cbf8c2775 100644 --- a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, IWebhookFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; export async function webflowApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -28,7 +28,7 @@ export async function webflowApiRequest( credentialsType = 'webflowOAuth2Api'; } - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { 'accept-version': '1.0.0', }, @@ -52,7 +52,7 @@ export async function webflowApiRequest( export async function webflowApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Wekan/GenericFunctions.ts b/packages/nodes-base/nodes/Wekan/GenericFunctions.ts index b91143888a..18e5afbd3e 100644 --- a/packages/nodes-base/nodes/Wekan/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wekan/GenericFunctions.ts @@ -1,15 +1,15 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, } from 'n8n-workflow'; export async function apiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: object, query?: IDataObject, @@ -18,7 +18,7 @@ export async function apiRequest( query = query || {}; - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { Accept: 'application/json', }, diff --git a/packages/nodes-base/nodes/Wekan/Wekan.node.ts b/packages/nodes-base/nodes/Wekan/Wekan.node.ts index ff1d3043bb..b3a8501f47 100644 --- a/packages/nodes-base/nodes/Wekan/Wekan.node.ts +++ b/packages/nodes-base/nodes/Wekan/Wekan.node.ts @@ -6,6 +6,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -247,7 +248,7 @@ export class Wekan implements INodeType { // For Query string let qs: IDataObject; - let requestMethod: string; + let requestMethod: IHttpRequestMethods; let endpoint: string; for (let i = 0; i < items.length; i++) { diff --git a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts index 004c783146..f2519b17e5 100644 --- a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts @@ -1,5 +1,4 @@ import { createHash } from 'crypto'; -import type { OptionsWithUri } from 'request'; import type { ICredentialDataDecryptedObject, @@ -8,6 +7,8 @@ import type { IHookFunctions, ILoadOptionsFunctions, IWebhookFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { snakeCase } from 'change-case'; @@ -17,7 +18,7 @@ import type { ICouponLine, IFeeLine, ILineItem, IShoppingLine } from './OrderInt export async function woocommerceApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -27,7 +28,7 @@ export async function woocommerceApiRequest( ): Promise { const credentials = await this.getCredentials('wooCommerceApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, qs, body, @@ -44,7 +45,7 @@ export async function woocommerceApiRequest( export async function woocommerceApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts index 3ebfc583d8..ac0feb564c 100644 --- a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function wordpressApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -20,7 +20,7 @@ export async function wordpressApiRequest( ): Promise { const credentials = await this.getCredentials('wordpressApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -47,7 +47,7 @@ export async function wordpressApiRequest( export async function wordpressApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Workable/GenericFunctions.ts b/packages/nodes-base/nodes/Workable/GenericFunctions.ts index f855a66f10..8b6dbc7eae 100644 --- a/packages/nodes-base/nodes/Workable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Workable/GenericFunctions.ts @@ -1,17 +1,17 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function workableApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -24,7 +24,7 @@ export async function workableApiRequest( subdomain: string; }; - let options: OptionsWithUri = { + let options: IRequestOptions = { headers: { Authorization: `Bearer ${credentials.accessToken}` }, method, qs, diff --git a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts index 4277cb50e6..9007d215a8 100644 --- a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts @@ -1,15 +1,15 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, + IHttpRequestMethods, ILoadOptionsFunctions, + IRequestOptions, } from 'n8n-workflow'; export async function wufooApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -19,7 +19,7 @@ export async function wufooApiRequest( ): Promise { const credentials = await this.getCredentials('wufooApi'); - let options: OptionsWithUri = { + let options: IRequestOptions = { method, form: body, body, diff --git a/packages/nodes-base/nodes/Xero/GenericFunctions.ts b/packages/nodes-base/nodes/Xero/GenericFunctions.ts index 02037e9f68..c1d7d37228 100644 --- a/packages/nodes-base/nodes/Xero/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Xero/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function xeroApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -18,7 +18,7 @@ export async function xeroApiRequest( uri?: string, headers: IDataObject = {}, ): Promise { - const options: OptionsWithUri = { + const options: IRequestOptions = { headers: { 'Content-Type': 'application/json', }, @@ -48,7 +48,7 @@ export async function xeroApiRequest( export async function xeroApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Yourls/GenericFunctions.ts b/packages/nodes-base/nodes/Yourls/GenericFunctions.ts index 7555eeafd9..c847c0714d 100644 --- a/packages/nodes-base/nodes/Yourls/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Yourls/GenericFunctions.ts @@ -1,16 +1,16 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function yourlsApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, body: any = {}, qs: IDataObject = {}, @@ -20,7 +20,7 @@ export async function yourlsApiRequest( qs.signature = credentials.signature as string; qs.format = 'json'; - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, diff --git a/packages/nodes-base/nodes/Zammad/GenericFunctions.ts b/packages/nodes-base/nodes/Zammad/GenericFunctions.ts index 91d1e2e520..aad3fa3d84 100644 --- a/packages/nodes-base/nodes/Zammad/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zammad/GenericFunctions.ts @@ -3,11 +3,11 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + IRequestOptions, + IHttpRequestMethods, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import flow from 'lodash/flow'; import type { Zammad } from './types'; @@ -18,12 +18,12 @@ export function tolerateTrailingSlash(url: string) { export async function zammadApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, ) { - const options: OptionsWithUri = { + const options: IRequestOptions = { method, body, qs, @@ -85,7 +85,7 @@ export async function zammadApiRequest( export async function zammadApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Zammad/Zammad.node.ts b/packages/nodes-base/nodes/Zammad/Zammad.node.ts index 24ef44a898..8441fa0d01 100644 --- a/packages/nodes-base/nodes/Zammad/Zammad.node.ts +++ b/packages/nodes-base/nodes/Zammad/Zammad.node.ts @@ -8,11 +8,10 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + IRequestOptions, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; -import type { OptionsWithUri } from 'request'; - import { groupDescription, organizationDescription, @@ -256,7 +255,7 @@ export class Zammad implements INodeType { const baseUrl = tolerateTrailingSlash(credentials.baseUrl); - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'GET', uri: `${baseUrl}/api/v1/users/me`, json: true, @@ -289,7 +288,7 @@ export class Zammad implements INodeType { const baseUrl = tolerateTrailingSlash(credentials.baseUrl); - const options: OptionsWithUri = { + const options: IRequestOptions = { method: 'GET', uri: `${baseUrl}/api/v1/users/me`, json: true, diff --git a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts index 47ee5ab6d8..d38f741e4e 100644 --- a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts @@ -1,10 +1,10 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; function getUri(resource: string, subdomain: string) { @@ -17,7 +17,7 @@ function getUri(resource: string, subdomain: string) { export async function zendeskApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, @@ -35,7 +35,7 @@ export async function zendeskApiRequest( credentials = (await this.getCredentials('zendeskOAuth2Api')) as { subdomain: string }; } - let options: OptionsWithUri = { + let options: IRequestOptions = { method, qs, body, @@ -63,7 +63,7 @@ export async function zendeskApiRequest( export async function zendeskApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, resource: string, body: any = {}, diff --git a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts index 2536fb68c6..8184aede82 100644 --- a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts @@ -1,11 +1,11 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, IHookFunctions, IDataObject, ILoadOptionsFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -41,7 +41,7 @@ export function throwOnErrorStatus( export async function zohoApiRequest( this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -51,7 +51,7 @@ export async function zohoApiRequest( 'zohoOAuth2Api', )) as ZohoOAuth2ApiCredentials; - const options: OptionsWithUri = { + const options: IRequestOptions = { body: { data: [body], }, @@ -91,7 +91,7 @@ export async function zohoApiRequest( */ export async function zohoApiRequestAllItems( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, @@ -117,7 +117,7 @@ export async function zohoApiRequestAllItems( */ export async function handleListing( this: IExecuteFunctions, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts index 16ed299fb9..e02bbf642a 100644 --- a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts @@ -1,25 +1,25 @@ -import type { OptionsWithUri } from 'request'; - import type { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function zoomApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: object = {}, - query: object = {}, + query: IDataObject = {}, headers: IDataObject | undefined = undefined, option: IDataObject = {}, ) { const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; - let options: OptionsWithUri = { + let options: IRequestOptions = { method, headers: headers || { 'Content-Type': 'application/json', @@ -59,7 +59,7 @@ async function wait() { export async function zoomApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, - method: string, + method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, query: IDataObject = {}, diff --git a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts index 15110bb6ed..12ef28ab5b 100644 --- a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts @@ -1,5 +1,3 @@ -import type { OptionsWithUri } from 'request'; - import type { IDataObject, IExecuteFunctions, @@ -7,6 +5,8 @@ import type { IHookFunctions, IWebhookFunctions, JsonObject, + IHttpRequestMethods, + IRequestOptions, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -16,7 +16,7 @@ import type { IUser } from './UserInterface'; export async function zulipApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, - method: string, + method: IHttpRequestMethods, resource: string, body: IMessage | IStream | IUser = {}, @@ -28,7 +28,7 @@ export async function zulipApiRequest( const endpoint = `${credentials.url.toString().replace(new RegExp('/$'), '')}/api/v1`; - let options: OptionsWithUri = { + let options: IRequestOptions = { auth: { user: credentials.email as string, password: credentials.apiKey as string, @@ -37,7 +37,7 @@ export async function zulipApiRequest( 'Content-Type': 'application/x-www-form-urlencoded', }, method, - form: body, + form: body as IDataObject, qs: query, uri: uri || `${endpoint}${resource}`, json: true, diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 18d123af51..f48b9a176a 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -818,7 +818,6 @@ "@types/node-ssh": "^7.0.1", "@types/nodemailer": "^6.4.14", "@types/promise-ftp": "^1.3.4", - "@types/request-promise-native": "~1.0.15", "@types/rfc2047": "^2.0.1", "@types/showdown": "^1.9.4", "@types/snowflake-sdk": "^1.6.20", diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 71129dca01..069ade81c2 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -4,8 +4,6 @@ import type * as express from 'express'; import type FormData from 'form-data'; import type { PathLike } from 'fs'; import type { IncomingHttpHeaders } from 'http'; -import type { OptionsWithUri, OptionsWithUrl } from 'request'; -import type { RequestPromiseOptions } from 'request-promise-native'; import type { Readable } from 'stream'; import type { URLSearchParams } from 'url'; @@ -20,6 +18,7 @@ import type { WorkflowOperationError } from './errors/workflow-operation.error'; import type { WorkflowHooks } from './WorkflowHooks'; import type { NodeOperationError } from './errors/node-operation.error'; import type { NodeApiError } from './errors/node-api.error'; +import type { AxiosProxyConfig } from 'axios'; export interface IAdditionalCredentialOptions { oauth2?: IOAuth2Options; @@ -493,6 +492,7 @@ export interface IExecuteContextData { export type IHttpRequestMethods = 'DELETE' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT'; +/** used in helpers.httpRequest(WithAuthentication) */ export interface IHttpRequestOptions { url: string; baseURL?: string; @@ -524,6 +524,45 @@ export interface IHttpRequestOptions { json?: boolean; } +/** + * used in helpers.request(WithAuthentication) + * @see IHttpRequestOptions + * @deprecated Prefer using IHttpRequestOptions + */ +export interface IRequestOptions { + baseURL?: string; + uri?: string; + url?: string; + method?: IHttpRequestMethods; + qs?: IDataObject; + qsStringifyOptions?: { arrayFormat: 'repeat' | 'brackets' | 'indices' }; + useQuerystring?: boolean; + headers?: IDataObject; + auth?: Partial<{ + sendImmediately: boolean; + bearer: string; + user: string; + username: string; + password: string; + pass: string; + }>; + body?: any; + formData?: IDataObject | FormData; + form?: IDataObject | FormData; + json?: boolean; + useStream?: boolean; + encoding?: string | null; + followRedirect?: boolean; + followAllRedirects?: boolean; + timeout?: number; + rejectUnauthorized?: boolean; + proxy?: string | AxiosProxyConfig; + simple?: boolean; + gzip?: boolean; + maxRedirects?: number; + resolveWithFullResponse?: boolean; +} + export interface PaginationOptions { binaryResult?: boolean; continue: boolean | string; @@ -715,15 +754,6 @@ export interface NodeHelperFunctions { } export interface RequestHelperFunctions { - request(uriOrObject: string | IDataObject | any, options?: IDataObject): Promise; - requestWithAuthentication( - this: IAllExecuteFunctions, - credentialsType: string, - requestOptions: OptionsWithUri | RequestPromiseOptions, - additionalCredentialOptions?: IAdditionalCredentialOptions, - itemIndex?: number, - ): Promise; - httpRequest(requestOptions: IHttpRequestOptions): Promise; httpRequestWithAuthentication( this: IAllExecuteFunctions, @@ -733,22 +763,46 @@ export interface RequestHelperFunctions { ): Promise; requestWithAuthenticationPaginated( this: IAllExecuteFunctions, - requestOptions: OptionsWithUri, + requestOptions: IRequestOptions, itemIndex: number, paginationOptions: PaginationOptions, credentialsType?: string, additionalCredentialOptions?: IAdditionalCredentialOptions, ): Promise; + /** + * @deprecated Use .httpRequest instead + * @see RequestHelperFunctions.httpRequest + */ + request(uriOrObject: string | IRequestOptions, options?: IRequestOptions): Promise; + /** + * @deprecated Use .httpRequestWithAuthentication instead + * @see RequestHelperFunctions.requestWithAuthentication + */ + requestWithAuthentication( + this: IAllExecuteFunctions, + credentialsType: string, + requestOptions: IRequestOptions, + additionalCredentialOptions?: IAdditionalCredentialOptions, + itemIndex?: number, + ): Promise; + /** + * @deprecated Use .httpRequestWithAuthentication instead + * @see RequestHelperFunctions.requestWithAuthentication + */ requestOAuth1( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUrl | RequestPromiseOptions, + requestOptions: IRequestOptions, ): Promise; + /** + * @deprecated Use .httpRequestWithAuthentication instead + * @see RequestHelperFunctions.requestWithAuthentication + */ requestOAuth2( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUri | RequestPromiseOptions, + requestOptions: IRequestOptions, oAuth2Options?: IOAuth2Options, ): Promise; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3dba35758b..d6a76f8fac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -290,9 +290,6 @@ importers: '@types/json-schema': specifier: ^7.0.12 version: 7.0.12 - '@types/request-promise-native': - specifier: ~1.0.15 - version: 1.0.18 '@types/temp': specifier: ^0.9.1 version: 0.9.4 @@ -810,9 +807,6 @@ importers: '@types/mime-types': specifier: ^2.1.0 version: 2.1.1 - '@types/request-promise-native': - specifier: ~1.0.15 - version: 1.0.18 '@types/uuid': specifier: ^8.3.2 version: 8.3.4 @@ -1465,9 +1459,6 @@ importers: '@types/promise-ftp': specifier: ^1.3.4 version: 1.3.4 - '@types/request-promise-native': - specifier: ~1.0.15 - version: 1.0.18 '@types/rfc2047': specifier: ^2.0.1 version: 2.0.1 @@ -10109,10 +10100,6 @@ packages: '@types/connect': 3.4.35 '@types/node': 18.16.16 - /@types/caseless@0.12.2: - resolution: {integrity: sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==} - dev: true - /@types/cheerio@0.22.31: resolution: {integrity: sha512-Kt7Cdjjdi2XWSfrZ53v4Of0wG3ZcmaegFXjMmz9tfNrZSkzzo36G0AL1YqSdcIA78Etjt6E609pt5h1xnQkPUw==} dependencies: @@ -10579,21 +10566,6 @@ packages: resolution: {integrity: sha512-3ecTmnzB90sgarVpIszCF1cX2cnxwqDovWb31jGrKfxAL0Knui1H7Reaz/zlT9zaE3u0un7L5cNy9fQPy0d2sg==} dev: true - /@types/request-promise-native@1.0.18: - resolution: {integrity: sha512-tPnODeISFc/c1LjWyLuZUY+Z0uLB3+IMfNoQyDEi395+j6kTFTTRAqjENjoPJUid4vHRGEozoTrcTrfZM+AcbA==} - dependencies: - '@types/request': 2.48.8 - dev: true - - /@types/request@2.48.8: - resolution: {integrity: sha512-whjk1EDJPcAR2kYHRbFl/lKeeKYTi05A15K9bnLInCVroNDCtXce57xKdI0/rQaA3K+6q0eFyUBPmqfSndUZdQ==} - dependencies: - '@types/caseless': 0.12.2 - '@types/node': 18.16.16 - '@types/tough-cookie': 4.0.2 - form-data: 2.5.1 - dev: true - /@types/resolve@1.20.2: resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} dev: true @@ -16017,15 +15989,6 @@ packages: mime-types: 2.1.35 dev: true - /form-data@2.5.1: - resolution: {integrity: sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==} - engines: {node: '>= 0.12'} - dependencies: - asynckit: 0.4.0 - combined-stream: 1.0.8 - mime-types: 2.1.35 - dev: true - /form-data@3.0.1: resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} engines: {node: '>= 6'}